more tests
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
index 1c12952..a8c996e 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
@@ -3,6 +3,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Map;
 
 import org.junit.Test;
 
@@ -19,451 +20,451 @@
  * @version 1.0
  */
 public class AnnisQueryProcessorTest {
-	
-	String query;
-	ArrayList<JsonNode> operands;
 
-	QuerySerializer qs = new QuerySerializer();
-	ObjectMapper mapper = new ObjectMapper();
-	JsonNode res;
+    String query;
+    ArrayList<JsonNode> operands;
 
-	@Test
-	public void testContext() throws JsonProcessingException, IOException {
-		String contextUrl = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld";
-		query = "foo";
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals(contextUrl, res.get("@context").asText());
-	}
-	
-	@Test
-	public void testSingleTokens() throws JsonProcessingException, IOException {
-		query = "\"Mann\"";
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:token",			 res.at("/query/@type").asText());
-		assertEquals("korap:term",			 res.at("/query/wrap/@type").asText());
-		assertEquals("orth",				 res.at("/query/wrap/layer").asText());
-		assertEquals("Mann",				 res.at("/query/wrap/key").asText());
-		assertEquals("match:eq",			 res.at("/query/wrap/match").asText());
-		
-		query = "tok!=\"Frau\"";
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:token",			 res.at("/query/@type").asText());
-		assertEquals("korap:term",			 res.at("/query/wrap/@type").asText());
-		assertEquals("orth",				 res.at("/query/wrap/layer").asText());
-		assertEquals("Frau",				 res.at("/query/wrap/key").asText());
-		assertEquals("match:ne",			 res.at("/query/wrap/match").asText());
-		
-		query = "tok";  // special keyword for token
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:token",			 res.at("/query/@type").asText());
-		
-		query = "Mann"; // no special keyword -> defaults to layer name
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:span",			 res.at("/query/@type").asText());
-		assertEquals("Mann",				 res.at("/query/layer").asText());
-	}
-	
-	@Test 
-	public void testSpans() throws JsonProcessingException, IOException {
-		query = "node"; // special keyword for general span
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:span",			 res.at("/query/@type").asText());
-		
-		query = "cat=\"np\"";  // cat is special keyword for spans
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:span",			 res.at("/query/@type").asText());
-		assertEquals("np",					 res.at("/query/key").asText());
-		assertEquals("c",					 res.at("/query/layer").asText());
-		
-		query = "cat=\"NP\"";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:span",			 res.at("/query/@type").asText());
-		assertEquals("NP",					 res.at("/query/key").asText());
-		assertEquals("c",					 res.at("/query/layer").asText());
-	}
-	
-	@Test
-	public void testRegex() throws JsonProcessingException, IOException {
-		query = "/Mann/";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:token",			 res.at("/query/@type").asText());
-		assertEquals("korap:term",			 res.at("/query/wrap/@type").asText());
-		assertEquals("type:regex",			 res.at("/query/wrap/type").asText());
-		assertEquals("orth",				 res.at("/query/wrap/layer").asText());
-		assertEquals("Mann",				 res.at("/query/wrap/key").asText());
-		assertEquals("match:eq",			 res.at("/query/wrap/match").asText());
-		
-		query = "/.*?Mann.*?/";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("type:regex",			res.at("/query/wrap/type").asText());
-		assertEquals(".*?Mann.*?",			res.at("/query/wrap/key").asText());
-	}
+    QuerySerializer qs = new QuerySerializer();
+    ObjectMapper mapper = new ObjectMapper();
+    JsonNode res;
 
-	@Test
-	public void testFoundriesLayers() throws JsonProcessingException, IOException {
-		query = "c=\"np\"";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:span",			 res.at("/query/@type").asText());
-		assertEquals("np",					 res.at("/query/key").asText());
-		assertEquals("c",					 res.at("/query/layer").asText());
-		
-		query = "cnx/c=\"np\"";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:span",			 res.at("/query/@type").asText());
-		assertEquals("np",					 res.at("/query/key").asText());
-		assertEquals("c",					 res.at("/query/layer").asText());
-		assertEquals("cnx",					 res.at("/query/foundry").asText());
-		
-		query = "tt/pos=\"np\"";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:token",			 res.at("/query/@type").asText());
-		assertEquals("korap:term",			 res.at("/query/wrap/@type").asText());
-		assertEquals("np",					 res.at("/query/wrap/key").asText());
-		assertEquals("p",					 res.at("/query/wrap/layer").asText());
-		assertEquals("tt",					 res.at("/query/wrap/foundry").asText());
-	}
-	
-	@Test
-	public void testDirectDeclarationRelations() throws JsonProcessingException, IOException {
-		query = "node > node";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:group",			res.at("/query/@type").asText());
-		assertEquals("operation:relation",	res.at("/query/operation").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
-		assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
-		assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
-		assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
-		assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
-		
-		query = "node > cnx/c=\"np\"";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:group",			res.at("/query/@type").asText());
-		assertEquals("operation:relation",	res.at("/query/operation").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
-		assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
-		assertEquals("np",					res.at("/query/operands/1/key").asText());
-		assertEquals("c",					res.at("/query/operands/1/layer").asText());
-		assertEquals("cnx",					res.at("/query/operands/1/foundry").asText());
-		assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
-		assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
-		assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
-		
-		query = "cnx/c=\"np\" > node";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals(true,					res.at("/query/operands/1/key").isMissingNode());
-		assertEquals("np",					res.at("/query/operands/0/key").asText());
-		
-		query = "cat=/NP/ & cat=/PP/ > #1";
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:group",			res.at("/query/@type").asText());
-		assertEquals("operation:relation",	res.at("/query/operation").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
-		assertEquals("PP",					res.at("/query/operands/0/key").asText());
-		assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
-		assertEquals("NP",					res.at("/query/operands/1/key").asText());
-		assertEquals(true,					res.at("/query/operands/2").isMissingNode());
-		assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
-		assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
-		assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
-	}
-	
-	@Test
-	public void testDefPredicationInversion() throws JsonProcessingException, IOException {
-		query = "#1 > #2 & cnx/cat=\"vp\" & cnx/cat=\"np\"";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:group",			res.at("/query/@type").asText());
-		assertEquals("operation:relation",	res.at("/query/operation").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
-		assertEquals("vp",					res.at("/query/operands/0/key").asText());
-		assertEquals("c",					res.at("/query/operands/0/layer").asText());
-		assertEquals("cnx",					res.at("/query/operands/0/foundry").asText());
-		assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
-		assertEquals("np",					res.at("/query/operands/1/key").asText());
-		assertEquals("c",					res.at("/query/operands/1/layer").asText());
-		assertEquals("cnx",					res.at("/query/operands/1/foundry").asText());
-		assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
-		assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
-		assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
-	}
-	
-	@Test
-	public void testSimpleDominance() throws JsonProcessingException, IOException {
-		query = "node & node & #2 > #1";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:group",			res.at("/query/@type").asText());
-		assertEquals("operation:relation",	res.at("/query/operation").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
-		assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
-		assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
-		assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
-		assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
-		
-		query = "\"Mann\" & node & #2 > #1";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:group",			res.at("/query/@type").asText());
-		assertEquals("operation:relation",	res.at("/query/operation").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
-		assertEquals("korap:token",			res.at("/query/operands/1/@type").asText());
-		assertEquals("Mann",				res.at("/query/operands/1/wrap/key").asText());
-		assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
-		assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
-		assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
-		
-		query = "\"Mann\" & node & #2 >[func=\"SB\"] #1";  //coordinates the func=SB term and requires a "c"-layer term (consituency relation/dominance)
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
-		assertEquals("korap:termGroup",		res.at("/query/relation/wrap/@type").asText());
-		assertEquals("relation:and",		res.at("/query/relation/wrap/relation").asText());
-		assertEquals("c",					res.at("/query/relation/wrap/operands/1/layer").asText());
-		assertEquals("func",				res.at("/query/relation/wrap/operands/0/layer").asText());
-		assertEquals("SB",					res.at("/query/relation/wrap/operands/0/key").asText());
-		
-		query = "cat=\"S\" & node & #1 >[func=\"SB\" func=\"MO\"] #2";  // quite meaningless (function is subject and modifier), but this is allowed by Annis, however its backend only regards the 1st option
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
-		assertEquals("korap:termGroup",		res.at("/query/relation/wrap/@type").asText());
-		assertEquals("relation:and",		res.at("/query/relation/wrap/relation").asText());
-		assertEquals("func",				res.at("/query/relation/wrap/operands/0/layer").asText());
-		assertEquals("SB",					res.at("/query/relation/wrap/operands/0/key").asText());
-		assertEquals("func",				res.at("/query/relation/wrap/operands/1/layer").asText());
-		assertEquals("MO"	,				res.at("/query/relation/wrap/operands/1/key").asText());
-		assertEquals("c",					res.at("/query/relation/wrap/operands/2/layer").asText());
-		
-		query = "cat=\"S\" & cat=\"NP\" & #1 >@l #2";  // all sentences starting with NP  -> wrap relation in startswith and retrieve 2nd operand with focus
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("operation:position",	res.at("/query/operation").asText());
-		assertEquals("operation:relation",	res.at("/query/operands/0/operation").asText());
-		assertEquals("frames:startswith",	res.at("/query/frames/0").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/operands/0/@type").asText());
-		assertEquals("S",					res.at("/query/operands/0/operands/0/key").asText());
-		assertEquals("korap:group",			res.at("/query/operands/0/operands/1/@type").asText());
-		assertEquals("operation:class",		res.at("/query/operands/0/operands/1/operation").asText());
-		assertEquals(129,					res.at("/query/operands/0/operands/1/classOut").asInt());
-		assertEquals("korap:span",			res.at("/query/operands/0/operands/1/operands/0/@type").asText());
-		assertEquals("NP",					res.at("/query/operands/0/operands/1/operands/0/key").asText());
-		assertEquals("korap:reference",		res.at("/query/operands/1/@type").asText());
-		assertEquals("operation:focus",		res.at("/query/operands/1/operation").asText());
-		assertEquals(129,					res.at("/query/operands/1/classRef/0").asInt());
-		
-		query = "cat=\"S\" & cat=\"NP\" & #1 >@r #2";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("operation:position",	res.at("/query/operation").asText());
-		assertEquals("operation:relation",	res.at("/query/operands/0/operation").asText());
-		assertEquals("frames:endswith",		res.at("/query/frames/0").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/operands/0/@type").asText());
-		assertEquals("S",					res.at("/query/operands/0/operands/0/key").asText());
-		assertEquals("korap:group",			res.at("/query/operands/0/operands/1/@type").asText());
-		assertEquals("operation:class",		res.at("/query/operands/0/operands/1/operation").asText());
-		assertEquals(129,					res.at("/query/operands/0/operands/1/classOut").asInt());
-		assertEquals("korap:span",			res.at("/query/operands/0/operands/1/operands/0/@type").asText());
-		assertEquals("NP",					res.at("/query/operands/0/operands/1/operands/0/key").asText());
-		assertEquals("korap:reference",		res.at("/query/operands/1/@type").asText());
-		assertEquals("operation:focus",		res.at("/query/operands/1/operation").asText());
-		assertEquals(129,					res.at("/query/operands/1/classRef/0").asInt());
-	}
-	
-	@Test
-	public void testIndirectDominance() throws JsonProcessingException, IOException {
-		query = "node & node & #1 >2,4 #2";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:group",			res.at("/query/@type").asText());
-		assertEquals("operation:relation",	res.at("/query/operation").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
-		assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
-		assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
-		assertEquals(2,						res.at("/query/relation/boundary/min").asInt());
-		assertEquals(4,						res.at("/query/relation/boundary/max").asInt());
-		assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
-		assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
-		
-		query = "node & node & #1 >* #2";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals(0,						res.at("/query/relation/boundary/min").asInt());
-		assertEquals(true,					res.at("/query/relation/boundary/max").isMissingNode());
-	}
+    @Test
+    public void testContext() throws JsonProcessingException, IOException {
+        String contextUrl = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld";
+        query = "foo";
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals(contextUrl, res.get("@context").asText());
+    }
 
-		
-	@Test
-	public void testMultipleDominance() throws JsonProcessingException, IOException {
-		query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & #1 > #2 > #3";  
-		qs.setQuery(query, "annis");
-		res = mapper.readTree(qs.toJSON());
-		assertEquals("korap:group",			res.at("/query/@type").asText());
-		assertEquals("operation:relation",	res.at("/query/operation").asText());
-		assertEquals("korap:reference",		res.at("/query/operands/0/@type").asText());
-		assertEquals("operation:focus",		res.at("/query/operands/0/operation").asText());
-		assertEquals(128,					res.at("/query/operands/0/classRef/0").asInt());
-		assertEquals("korap:group",			res.at("/query/operands/0/operands/0/@type").asText());
-		assertEquals("operation:relation",	res.at("/query/operands/0/operands/0/operation").asText());
-		assertEquals("korap:relation",		res.at("/query/operands/0/operands/0/relation/@type").asText());
-		assertEquals("c",					res.at("/query/operands/0/operands/0/relation/wrap/layer").asText());
-		assertEquals("korap:span",			res.at("/query/operands/0/operands/0/operands/0/@type").asText());
-		assertEquals("c",					res.at("/query/operands/0/operands/0/operands/0/layer").asText());
-		assertEquals("CP",					res.at("/query/operands/0/operands/0/operands/0/key").asText());
-		assertEquals("korap:group",			res.at("/query/operands/0/operands/0/operands/1/@type").asText());
-		assertEquals("operation:class",		res.at("/query/operands/0/operands/0/operands/1/operation").asText());
-		assertEquals(128,					res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
-		assertEquals("VP",					res.at("/query/operands/0/operands/0/operands/1/operands/0/key").asText());
-	}
-//		query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & #1 > #2 > #3";
-//		String dom1 = 
-//				"{@type=korap:group, operation=operation:relation, operands=[" +
-//						"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//							"{@type=korap:group, operation=operation:relation, operands=[" +
-//								"{@type=korap:span, layer=cat, key=CP, match=match:eq}," +
-//								"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//									"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
-//								"]}" +
-//							"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//						"]}," +
-//						"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
-//				"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & cat=\"DP\" & #1 > #2 > #3 > #4";
-//		String dom2 = 
-//				"{@type=korap:group, operation=operation:relation, operands=[" +
-//						"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
-//							"{@type=korap:group, operation=operation:relation, operands=[" +
-//								"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//									"{@type=korap:group, operation=operation:relation, operands=[" +
-//										"{@type=korap:span, layer=cat, key=CP, match=match:eq}," +
-//										"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//											"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
-//										"]}" +
-//									"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//								"]}," +
-//								"{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
-//									"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
-//								"]}" +
-//							"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//						"]}," +
-//						"{@type=korap:span, layer=cat, key=DP, match=match:eq}" +
-//					"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//	}
-//	
-//	@Test
-//	public void testPointingRelations() throws Exception {
-//		query = "node & node & #2 ->coref[val=\"true\"] #1";
-//		String dom1 = 
-//				"{@type=korap:group, operation=operation:relation, operands=[" +
-//						"{@type=korap:span}," +
-//						"{@type=korap:span}" +
-//				"], relation={@type=korap:relation, wrap={@type=korap:term, layer=coref, key=true, match=match:eq}}" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "node & node & #2 ->mate/coref[val=\"true\"] #1";
-//		String dom2 = 
-//				"{@type=korap:group, operation=operation:relation, operands=[" +
-//						"{@type=korap:span}," +
-//						"{@type=korap:span}" +
-//				"], relation={@type=korap:relation, wrap={@type=korap:term, foundry=mate, layer=coref, key=true, match=match:eq}}" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//	}
-//	
-//	@Test
-//	public void testSequence() throws Exception {
-//		query = "node & node & #1 . #2";
-//		String seq1 = 
-//				"{@type=korap:group, operation=operation:sequence, " +
-//					"operands=[" +
-//						"{@type=korap:span}," +
-//						"{@type=korap:span}" +
-//					"], inOrder=true" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "node & node & #1 .* #2";
-//		String seq2 = 
-//				"{@type=korap:group, operation=operation:sequence, operands=[" +
-//						"{@type=korap:span}," +
-//						"{@type=korap:span}" +
-//					"], distances=[" +
-//						"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0}, min=0}" +
-//					"], inOrder=true" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "node & node & #1 .2,3 #2";
-//		String seq3 = 
-//				"{@type=korap:group, operation=operation:sequence, operands=[" +
-//						"{@type=korap:span}," +
-//						"{@type=korap:span}" +
-//					"], distances=[" +
-//						"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=3}, min=2, max=3}" +
-//					"], inOrder=true" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//	}
-//	
-	@Test
-	public void testMultipleSequence() throws Exception {
-		query = "tok=\"a\" & tok=\"b\" & tok=\"c\" & #1 . #2 & #2 . #3";
-		String seq4 = 
-				"{@type=korap:group, operation=operation:sequence," +
-					"operands=[" +
-						"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-							"{@type=korap:group, operation=operation:sequence, operands=[" +
-								"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
-								"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-									"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
-								"]}" +
-							"], distances=[" +
-								"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
-							"], inOrder=true}" +
-						"]}," +	
-						"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
-					"],distances=[" +
-						"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
-					"], inOrder=true" +
-				"}";
+    @Test
+    public void testSingleTokens() throws JsonProcessingException, IOException {
+        query = "\"Mann\"";
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:token",			 res.at("/query/@type").asText());
+        assertEquals("korap:term",			 res.at("/query/wrap/@type").asText());
+        assertEquals("orth",				 res.at("/query/wrap/layer").asText());
+        assertEquals("Mann",				 res.at("/query/wrap/key").asText());
+        assertEquals("match:eq",			 res.at("/query/wrap/match").asText());
+
+        query = "tok!=\"Frau\"";
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:token",			 res.at("/query/@type").asText());
+        assertEquals("korap:term",			 res.at("/query/wrap/@type").asText());
+        assertEquals("orth",				 res.at("/query/wrap/layer").asText());
+        assertEquals("Frau",				 res.at("/query/wrap/key").asText());
+        assertEquals("match:ne",			 res.at("/query/wrap/match").asText());
+
+        query = "tok";  // special keyword for token
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:token",			 res.at("/query/@type").asText());
+
+        query = "Mann"; // no special keyword -> defaults to layer name
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:span",			 res.at("/query/@type").asText());
+        assertEquals("Mann",				 res.at("/query/layer").asText());
+    }
+
+    @Test 
+    public void testSpans() throws JsonProcessingException, IOException {
+        query = "node"; // special keyword for general span
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:span",			 res.at("/query/@type").asText());
+
+        query = "cat=\"np\"";  // cat is special keyword for spans
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:span",			 res.at("/query/@type").asText());
+        assertEquals("np",					 res.at("/query/key").asText());
+        assertEquals("c",					 res.at("/query/layer").asText());
+
+        query = "cat=\"NP\"";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:span",			 res.at("/query/@type").asText());
+        assertEquals("NP",					 res.at("/query/key").asText());
+        assertEquals("c",					 res.at("/query/layer").asText());
+    }
+
+    @Test
+    public void testRegex() throws JsonProcessingException, IOException {
+        query = "/Mann/";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:token",			 res.at("/query/@type").asText());
+        assertEquals("korap:term",			 res.at("/query/wrap/@type").asText());
+        assertEquals("type:regex",			 res.at("/query/wrap/type").asText());
+        assertEquals("orth",				 res.at("/query/wrap/layer").asText());
+        assertEquals("Mann",				 res.at("/query/wrap/key").asText());
+        assertEquals("match:eq",			 res.at("/query/wrap/match").asText());
+
+        query = "/.*?Mann.*?/";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("type:regex",			res.at("/query/wrap/type").asText());
+        assertEquals(".*?Mann.*?",			res.at("/query/wrap/key").asText());
+    }
+
+    @Test
+    public void testFoundriesLayers() throws JsonProcessingException, IOException {
+        query = "c=\"np\"";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:span",			 res.at("/query/@type").asText());
+        assertEquals("np",					 res.at("/query/key").asText());
+        assertEquals("c",					 res.at("/query/layer").asText());
+
+        query = "cnx/c=\"np\"";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:span",			 res.at("/query/@type").asText());
+        assertEquals("np",					 res.at("/query/key").asText());
+        assertEquals("c",					 res.at("/query/layer").asText());
+        assertEquals("cnx",					 res.at("/query/foundry").asText());
+
+        query = "tt/pos=\"np\"";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:token",			 res.at("/query/@type").asText());
+        assertEquals("korap:term",			 res.at("/query/wrap/@type").asText());
+        assertEquals("np",					 res.at("/query/wrap/key").asText());
+        assertEquals("p",					 res.at("/query/wrap/layer").asText());
+        assertEquals("tt",					 res.at("/query/wrap/foundry").asText());
+    }
+
+    @Test
+    public void testDirectDeclarationRelations() throws JsonProcessingException, IOException {
+        query = "node > node";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",			res.at("/query/@type").asText());
+        assertEquals("operation:relation",	res.at("/query/operation").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
+        assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
+        assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
+        assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
+        assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
+
+        query = "node > cnx/c=\"np\"";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",			res.at("/query/@type").asText());
+        assertEquals("operation:relation",	res.at("/query/operation").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
+        assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
+        assertEquals("np",					res.at("/query/operands/1/key").asText());
+        assertEquals("c",					res.at("/query/operands/1/layer").asText());
+        assertEquals("cnx",					res.at("/query/operands/1/foundry").asText());
+        assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
+        assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
+        assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
+
+        query = "cnx/c=\"np\" > node";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals(true,					res.at("/query/operands/1/key").isMissingNode());
+        assertEquals("np",					res.at("/query/operands/0/key").asText());
+
+        query = "cat=/NP/ & cat=/PP/ > #1";
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",			res.at("/query/@type").asText());
+        assertEquals("operation:relation",	res.at("/query/operation").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
+        assertEquals("PP",					res.at("/query/operands/0/key").asText());
+        assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
+        assertEquals("NP",					res.at("/query/operands/1/key").asText());
+        assertEquals(true,					res.at("/query/operands/2").isMissingNode());
+        assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
+        assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
+        assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
+    }
+
+    @Test
+    public void testDefPredicationInversion() throws JsonProcessingException, IOException {
+        query = "#1 > #2 & cnx/cat=\"vp\" & cnx/cat=\"np\"";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",			res.at("/query/@type").asText());
+        assertEquals("operation:relation",	res.at("/query/operation").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
+        assertEquals("vp",					res.at("/query/operands/0/key").asText());
+        assertEquals("c",					res.at("/query/operands/0/layer").asText());
+        assertEquals("cnx",					res.at("/query/operands/0/foundry").asText());
+        assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
+        assertEquals("np",					res.at("/query/operands/1/key").asText());
+        assertEquals("c",					res.at("/query/operands/1/layer").asText());
+        assertEquals("cnx",					res.at("/query/operands/1/foundry").asText());
+        assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
+        assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
+        assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
+    }
+
+    @Test
+    public void testSimpleDominance() throws JsonProcessingException, IOException {
+        query = "node & node & #2 > #1";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",			res.at("/query/@type").asText());
+        assertEquals("operation:relation",	res.at("/query/operation").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
+        assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
+        assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
+        assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
+        assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
+
+        query = "\"Mann\" & node & #2 > #1";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",			res.at("/query/@type").asText());
+        assertEquals("operation:relation",	res.at("/query/operation").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
+        assertEquals("korap:token",			res.at("/query/operands/1/@type").asText());
+        assertEquals("Mann",				res.at("/query/operands/1/wrap/key").asText());
+        assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
+        assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
+        assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
+
+        query = "\"Mann\" & node & #2 >[func=\"SB\"] #1";  //coordinates the func=SB term and requires a "c"-layer term (consituency relation/dominance)
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
+        assertEquals("korap:termGroup",		res.at("/query/relation/wrap/@type").asText());
+        assertEquals("relation:and",		res.at("/query/relation/wrap/relation").asText());
+        assertEquals("c",					res.at("/query/relation/wrap/operands/1/layer").asText());
+        assertEquals("func",				res.at("/query/relation/wrap/operands/0/layer").asText());
+        assertEquals("SB",					res.at("/query/relation/wrap/operands/0/key").asText());
+
+        query = "cat=\"S\" & node & #1 >[func=\"SB\" func=\"MO\"] #2";  // quite meaningless (function is subject and modifier), but this is allowed by Annis, however its backend only regards the 1st option
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
+        assertEquals("korap:termGroup",		res.at("/query/relation/wrap/@type").asText());
+        assertEquals("relation:and",		res.at("/query/relation/wrap/relation").asText());
+        assertEquals("func",				res.at("/query/relation/wrap/operands/0/layer").asText());
+        assertEquals("SB",					res.at("/query/relation/wrap/operands/0/key").asText());
+        assertEquals("func",				res.at("/query/relation/wrap/operands/1/layer").asText());
+        assertEquals("MO"	,				res.at("/query/relation/wrap/operands/1/key").asText());
+        assertEquals("c",					res.at("/query/relation/wrap/operands/2/layer").asText());
+
+        query = "cat=\"S\" & cat=\"NP\" & #1 >@l #2";  // all sentences starting with NP  -> wrap relation in startswith and retrieve 2nd operand with focus
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("operation:position",	res.at("/query/operation").asText());
+        assertEquals("operation:relation",	res.at("/query/operands/0/operation").asText());
+        assertEquals("frames:startswith",	res.at("/query/frames/0").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/operands/0/@type").asText());
+        assertEquals("S",					res.at("/query/operands/0/operands/0/key").asText());
+        assertEquals("korap:group",			res.at("/query/operands/0/operands/1/@type").asText());
+        assertEquals("operation:class",		res.at("/query/operands/0/operands/1/operation").asText());
+        assertEquals(129,					res.at("/query/operands/0/operands/1/classOut").asInt());
+        assertEquals("korap:span",			res.at("/query/operands/0/operands/1/operands/0/@type").asText());
+        assertEquals("NP",					res.at("/query/operands/0/operands/1/operands/0/key").asText());
+        assertEquals("korap:reference",		res.at("/query/operands/1/@type").asText());
+        assertEquals("operation:focus",		res.at("/query/operands/1/operation").asText());
+        assertEquals(129,					res.at("/query/operands/1/classRef/0").asInt());
+
+        query = "cat=\"S\" & cat=\"NP\" & #1 >@r #2";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("operation:position",	res.at("/query/operation").asText());
+        assertEquals("operation:relation",	res.at("/query/operands/0/operation").asText());
+        assertEquals("frames:endswith",		res.at("/query/frames/0").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/operands/0/@type").asText());
+        assertEquals("S",					res.at("/query/operands/0/operands/0/key").asText());
+        assertEquals("korap:group",			res.at("/query/operands/0/operands/1/@type").asText());
+        assertEquals("operation:class",		res.at("/query/operands/0/operands/1/operation").asText());
+        assertEquals(129,					res.at("/query/operands/0/operands/1/classOut").asInt());
+        assertEquals("korap:span",			res.at("/query/operands/0/operands/1/operands/0/@type").asText());
+        assertEquals("NP",					res.at("/query/operands/0/operands/1/operands/0/key").asText());
+        assertEquals("korap:reference",		res.at("/query/operands/1/@type").asText());
+        assertEquals("operation:focus",		res.at("/query/operands/1/operation").asText());
+        assertEquals(129,					res.at("/query/operands/1/classRef/0").asInt());
+    }
+
+    @Test
+    public void testIndirectDominance() throws JsonProcessingException, IOException {
+        query = "node & node & #1 >2,4 #2";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",			res.at("/query/@type").asText());
+        assertEquals("operation:relation",	res.at("/query/operation").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/@type").asText());
+        assertEquals("korap:span",			res.at("/query/operands/1/@type").asText());
+        assertEquals("korap:relation",		res.at("/query/relation/@type").asText());
+        assertEquals(2,						res.at("/query/relation/boundary/min").asInt());
+        assertEquals(4,						res.at("/query/relation/boundary/max").asInt());
+        assertEquals("korap:term",			res.at("/query/relation/wrap/@type").asText());
+        assertEquals("c",					res.at("/query/relation/wrap/layer").asText());
+
+        query = "node & node & #1 >* #2";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals(0,						res.at("/query/relation/boundary/min").asInt());
+        assertEquals(true,					res.at("/query/relation/boundary/max").isMissingNode());
+    }
+
+
+    @Test
+    public void testMultipleDominance() throws JsonProcessingException, IOException {
+        query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & #1 > #2 > #3";  
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",			res.at("/query/@type").asText());
+        assertEquals("operation:relation",	res.at("/query/operation").asText());
+        assertEquals("korap:reference",		res.at("/query/operands/0/@type").asText());
+        assertEquals("operation:focus",		res.at("/query/operands/0/operation").asText());
+        assertEquals(128,					res.at("/query/operands/0/classRef/0").asInt());
+        assertEquals("korap:group",			res.at("/query/operands/0/operands/0/@type").asText());
+        assertEquals("operation:relation",	res.at("/query/operands/0/operands/0/operation").asText());
+        assertEquals("korap:relation",		res.at("/query/operands/0/operands/0/relation/@type").asText());
+        assertEquals("c",					res.at("/query/operands/0/operands/0/relation/wrap/layer").asText());
+        assertEquals("korap:span",			res.at("/query/operands/0/operands/0/operands/0/@type").asText());
+        assertEquals("c",					res.at("/query/operands/0/operands/0/operands/0/layer").asText());
+        assertEquals("CP",					res.at("/query/operands/0/operands/0/operands/0/key").asText());
+        assertEquals("korap:group",			res.at("/query/operands/0/operands/0/operands/1/@type").asText());
+        assertEquals("operation:class",		res.at("/query/operands/0/operands/0/operands/1/operation").asText());
+        assertEquals(128,					res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+        assertEquals("VP",					res.at("/query/operands/0/operands/0/operands/1/operands/0/key").asText());
+    }
+    //		query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & #1 > #2 > #3";
+    //		String dom1 = 
+    //				"{@type=korap:group, operation=operation:relation, operands=[" +
+    //						"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //							"{@type=korap:group, operation=operation:relation, operands=[" +
+    //								"{@type=korap:span, layer=cat, key=CP, match=match:eq}," +
+    //								"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //									"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
+    //								"]}" +
+    //							"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //						"]}," +
+    //						"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
+    //				"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & cat=\"DP\" & #1 > #2 > #3 > #4";
+    //		String dom2 = 
+    //				"{@type=korap:group, operation=operation:relation, operands=[" +
+    //						"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
+    //							"{@type=korap:group, operation=operation:relation, operands=[" +
+    //								"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //									"{@type=korap:group, operation=operation:relation, operands=[" +
+    //										"{@type=korap:span, layer=cat, key=CP, match=match:eq}," +
+    //										"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //											"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
+    //										"]}" +
+    //									"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //								"]}," +
+    //								"{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
+    //									"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
+    //								"]}" +
+    //							"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //						"]}," +
+    //						"{@type=korap:span, layer=cat, key=DP, match=match:eq}" +
+    //					"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //	}
+    //	
+    //	@Test
+    //	public void testPointingRelations() throws Exception {
+    //		query = "node & node & #2 ->coref[val=\"true\"] #1";
+    //		String dom1 = 
+    //				"{@type=korap:group, operation=operation:relation, operands=[" +
+    //						"{@type=korap:span}," +
+    //						"{@type=korap:span}" +
+    //				"], relation={@type=korap:relation, wrap={@type=korap:term, layer=coref, key=true, match=match:eq}}" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "node & node & #2 ->mate/coref[val=\"true\"] #1";
+    //		String dom2 = 
+    //				"{@type=korap:group, operation=operation:relation, operands=[" +
+    //						"{@type=korap:span}," +
+    //						"{@type=korap:span}" +
+    //				"], relation={@type=korap:relation, wrap={@type=korap:term, foundry=mate, layer=coref, key=true, match=match:eq}}" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //	}
+    //	
+    //	@Test
+    //	public void testSequence() throws Exception {
+    //		query = "node & node & #1 . #2";
+    //		String seq1 = 
+    //				"{@type=korap:group, operation=operation:sequence, " +
+    //					"operands=[" +
+    //						"{@type=korap:span}," +
+    //						"{@type=korap:span}" +
+    //					"], inOrder=true" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "node & node & #1 .* #2";
+    //		String seq2 = 
+    //				"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //						"{@type=korap:span}," +
+    //						"{@type=korap:span}" +
+    //					"], distances=[" +
+    //						"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0}, min=0}" +
+    //					"], inOrder=true" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "node & node & #1 .2,3 #2";
+    //		String seq3 = 
+    //				"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //						"{@type=korap:span}," +
+    //						"{@type=korap:span}" +
+    //					"], distances=[" +
+    //						"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=3}, min=2, max=3}" +
+    //					"], inOrder=true" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //	}
+    //	
+    @Test
+    public void testMultipleSequence() throws Exception {
+        query = "tok=\"a\" & tok=\"b\" & tok=\"c\" & #1 . #2 & #2 . #3";
+        String seq4 = 
+                "{@type=korap:group, operation=operation:sequence," +
+                        "operands=[" +
+                        "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+                        "{@type=korap:group, operation=operation:sequence, operands=[" +
+                        "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
+                        "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+                        "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
+                        "]}" +
+                        "], distances=[" +
+                        "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
+                        "], inOrder=true}" +
+                        "]}," +	
+                        "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
+                        "],distances=[" +
+                        "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
+                        "], inOrder=true" +
+                        "}";
         qs.setQuery(query, "annis");
         res = mapper.readTree(qs.toJSON());
         assertEquals("korap:group",         res.at("/query/@type").asText());
@@ -471,71 +472,71 @@
         assertEquals("korap:reference",     res.at("/query/operands/0/@type").asText());
         assertEquals(128,                   res.at("/query/operands/0/classRef/0").asInt());
         assertEquals(res.at("/query/operands/0/classRef/0").asInt(), 
-                     res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
-	}
+                res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+    }
 
-        
-//		
-//		query = "node & node & node & #1 . #2 .1,3 #3";
-//		String seq5 = 
-//				"{@type=korap:group, operation=operation:sequence, operands=[" +
-//						"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//							"{@type=korap:group, operation=operation:sequence, operands=[" +
-//								"{@type=korap:span}," +
-//								"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//									"{@type=korap:span}" +
-//								"]} "+
-//							"], inOrder=true}" +
-//						"]}," +
-//						"{@type=korap:span}" +
-//					"], distances=[" +
-//							"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
-//						"], inOrder=true" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(seq5.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "tok=\"Sonne\" & tok=\"Mond\" & tok=\"Sterne\" & tok=\"Himmel\" & #1 .0,2 #2 .0,4 #3 . #4";
-//		String seq6 = 
-//				"{@type=korap:group, operation=operation:sequence, operands=[" +
-//					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
-//						"{@type=korap:group, operation=operation:sequence, operands=[" +
-//							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//								"{@type=korap:group, operation=operation:sequence, operands=[" +
-//									"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
-//									"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//										"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
-//									"]}" +
-//								"], distances=[" +
-//									"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
-//								"], inOrder=true}" +
-//							"]}," +	
-//							"{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
-//								"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
-//							"]}" +
-//						"],distances=[" +
-//							"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
-//						"], inOrder=true}" +
-//					"]}," +
-//					"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Himmel, match=match:eq}}" +
-//				"], inOrder=true}" ;
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(seq6.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//	}
-//	
-	/**
-	 * Tests the (rather difficult) serialization of queries where two subsequent relations
-	 * do not share any common operand. Makes it impossible to wrap 2nd relation around 1st. 
-	 * Must therefore re-order relations (or postpone processing of 2nd).
-	 * @throws JsonProcessingException
-	 * @throws IOException
-	 */
-	@Test
+
+    //		
+    //		query = "node & node & node & #1 . #2 .1,3 #3";
+    //		String seq5 = 
+    //				"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //						"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //							"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //								"{@type=korap:span}," +
+    //								"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //									"{@type=korap:span}" +
+    //								"]} "+
+    //							"], inOrder=true}" +
+    //						"]}," +
+    //						"{@type=korap:span}" +
+    //					"], distances=[" +
+    //							"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=3}, min=1, max=3}" +
+    //						"], inOrder=true" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(seq5.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "tok=\"Sonne\" & tok=\"Mond\" & tok=\"Sterne\" & tok=\"Himmel\" & #1 .0,2 #2 .0,4 #3 . #4";
+    //		String seq6 = 
+    //				"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
+    //						"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //								"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //									"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
+    //									"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //										"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
+    //									"]}" +
+    //								"], distances=[" +
+    //									"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
+    //								"], inOrder=true}" +
+    //							"]}," +	
+    //							"{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
+    //								"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
+    //							"]}" +
+    //						"],distances=[" +
+    //							"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
+    //						"], inOrder=true}" +
+    //					"]}," +
+    //					"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Himmel, match=match:eq}}" +
+    //				"], inOrder=true}" ;
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(seq6.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //	}
+    //	
+    /**
+     * Tests the (rather difficult) serialization of queries where two subsequent relations
+     * do not share any common operand. Makes it impossible to wrap 2nd relation around 1st. 
+     * Must therefore re-order relations (or postpone processing of 2nd).
+     * @throws JsonProcessingException
+     * @throws IOException
+     */
+    @Test
     public void testNoSharedOperand() throws JsonProcessingException, IOException {
-	    query = "cat=\"A\" & cat=\"B\" & cat=\"C\" & cat=\"D\" & #1 . #2 & #3 . #4 & #1 > #3";  
-	    // the resulting query should be equivalent to PQ+:  focus(2:dominates(focus(1:{1:<A>}<B>),{2:<C>}))<D> 
+        query = "cat=\"A\" & cat=\"B\" & cat=\"C\" & cat=\"D\" & #1 . #2 & #3 . #4 & #1 > #3";  
+        // the resulting query should be equivalent to PQ+:  focus(2:dominates(focus(1:{1:<A>}<B>),{2:<C>}))<D> 
         qs.setQuery(query, "annis");
         res = mapper.readTree(qs.toJSON());
         assertEquals("korap:group",         res.at("/query/@type").asText());
@@ -553,7 +554,7 @@
         assertEquals("B",                   res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key").asText());
         assertEquals("C",                   res.at("/query/operands/0/operands/0/operands/1/operands/0/key").asText());
         assertEquals("D",                   res.at("/query/operands/1/key").asText());
-        
+
         query = "cat=\"A\" & cat=\"B\" & cat=\"C\" & cat=\"D\" & cat=\"E\" & cat=\"F\" & #1 . #2 & #3 . #4 & #5 . #6 & #1 > #3 & #3 > #5";  
         // the resulting query should be equivalent to PQ+:   focus(3:dominates(focus(2:dominates(focus(1:{1:<A>}<B>),{2:<C>}))<D>,{3:<E>}))<F> 
         qs.setQuery(query, "annis");
@@ -575,7 +576,7 @@
         assertEquals("D",                   res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key").asText());
         assertEquals("E",                   res.at("/query/operands/0/operands/0/operands/1/operands/0/key").asText());
         assertEquals("F",                   res.at("/query/operands/1/key").asText());
-        
+
         query = "cat=\"A\" & cat=\"B\" & cat=\"C\" & cat=\"D\" & #1 . #2 & #3 . #4";  
         // the resulting query should be equivalent to PQ+:  focus(2:dominates(focus(1:{1:<A>}<B>),{2:<C>}))<D> 
         qs.setQuery(query, "annis");
@@ -583,369 +584,379 @@
         assertEquals(true,         res.at("/query/@type").isMissingNode());
         assertEquals(StatusCodes.UNBOUND_ANNIS_RELATION,   res.at("/errors/0/0").asInt());
     }
-	
-//	@Test
-//	public void testMultipleMixedOperators() throws Exception {
-//		query = "tok=\"Sonne\" & tok=\"Mond\" & tok=\"Sterne\" & #1 > #2 .0,4 #3";
-//		String seq4 = 
-//					"{@type=korap:group, operation=operation:sequence, operands=[" +
-//							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//									"{@type=korap:group, operation=operation:relation, operands=[" +
-//										"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
-//										"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//											"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
-//										"]}" +
-//									"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//								"]}," +
-//								"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
-//						"], distances=[" +
-//							"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
-//						"], inOrder=true" +
-//					"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(seq4.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "tok=\"Sonne\" & tok=\"Mond\" & #1 > #2 .0,4  tok=\"Sterne\"";
-//		String seq5 = 
-//					"{@type=korap:group, operation=operation:sequence, operands=[" +
-//							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//									"{@type=korap:group, operation=operation:relation, operands=[" +
-//										"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
-//										"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//											"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
-//										"]}" +
-//									"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//								"]}," +
-//								"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
-//						"], distances=[" +
-//							"{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
-//						"], inOrder=true" +
-//					"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(seq5.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 > #3";
-//		String cp2 =
-//				"{@type=korap:group, operation=operation:relation, operands=[" +
-//					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
-//						"{@type=korap:group, operation=operation:relation, operands=[" +
-//							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//								"{@type=korap:group, operation=operation:relation, operands=[" +
-//									"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//										"{@type=korap:span}" +
-//									"]}," +
-//									"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
-//								"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//							"]}," +
-//							"{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
-//								"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
-//							"]}" +
-//						"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
-//						"}" +
-//					"]}," +
-//					"{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
-//				"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(cp2.replaceAll(" ", ""), map.replaceAll(" ", ""));		
-//	}
-//	/*
-//	@Test
-//	public void testMultipleOperatorsWithSameOperands() throws Exception {
-//		
-//		query = "cat=\"NP\" > cat=\"VP\" & #1 _l_ #2";
-//		String eq2 =
-//				"{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
-//						"{@type=korap:group, operation=operation:relation, operands=[" +
-//							"{@type=korap:group, operation=operation:class, class=, classOut=129, operands=[" +
-//								"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
-//							"]}," +
-//							"{@type=korap:group, operation=operation:class, class=, classOut=129, operands=[" +
-//								"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
-//							"]}" +
-//						"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}," +
-//					"{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
-//				"]" +
-//				"}"; // ???
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(eq2.replaceAll(" ", ""), map.replaceAll(" ", ""));		
-//	}
-//	*/
-//	@Test
-//	public void testPositions() throws Exception {
-//		query = "node & node & #2 _=_ #1";
-//		String pos1 = 
-//				"{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
-//						"{@type=korap:span}," +
-//						"{@type=korap:span}" +
-//				"], frame=frame:matches}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(pos1.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "node & node & #2 _i_ #1";
-//		String pos2 = 
-//				"{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
-//						"{@type=korap:span}," +
-//						"{@type=korap:span}" +
-//				"], frame=frame:contains" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(pos2.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "node & node & #2 _l_ #1";
-//		String pos3 = 
-//				"{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
-//						"{@type=korap:span}," +
-//						"{@type=korap:span}" +
-//				"], frame=frame:startswith" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "node & \"Mann\" & #1 _r_ #2";
-//		String pos4 = 
-//					"{@type=korap:group, operation=operation:position, frames=[frames:endswith], operands=[" +
-//						"{@type=korap:span}," +
-//						"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
-//						"], frame=frame:endswith" +
-//					"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "node & \"Mann\" & #2 _r_ #1";
-//		String pos5 = 
-//					"{@type=korap:group, operation=operation:position, frames=[frames:endswith], operands=[" +
-//						"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," +
-//						"{@type=korap:span}" +
-//						"], frame=frame:endswith" +
-//					"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//	}
-//	
-//	@Test
-//	public void testMultiplePredications() throws Exception {
-//		// a noun before a verb before a preposition
-//		query = "pos=\"N\" & pos=\"V\" & pos=\"P\" & #1 . #2 & #2 . #3"; 
-//		String mult1 = 
-//		"{@type=korap:group, operation=operation:sequence, operands=[" +
-//			"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//				"{@type=korap:group, operation=operation:sequence, operands=[" +
-//					"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}," +
-//					"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//						"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
-//					"]}" +
-//				"], inOrder=true}" +
-//			"]}," +
-//			"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
-//		"], inOrder=true}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(mult1.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		// a noun before a verb before a preposition
-//		query = "pos=\"N\" & pos=\"V\" & #1 . #2 & #2 . pos=\"P\""; 
-//		String mult2 = 
-//		"{@type=korap:group, operation=operation:sequence, operands=[" +
-//			"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//				"{@type=korap:group, operation=operation:sequence, operands=[" +
-//					"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}," +
-//					"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//						"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
-//					"]}" +
-//				"], inOrder=true}" +
-//			"]}," +
-//			"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
-//		"], inOrder=true}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(mult2.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//
-//		query = "pos=\"N\" & pos=\"V\" & pos=\"P\" & #1 > #2 & #1 > #3";
-//		String mult3 = 
-//			"{@type=korap:group, operation=operation:relation, operands=[" +
-//				"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//					"{@type=korap:group, operation=operation:relation, operands=[" +
-//						"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//							"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" +
-//						"]}," +
-//						"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
-//					"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//				"]}," +
-//				"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
-//			"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(mult3.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "cat=\"NP\" & pos=\"V\" & pos=\"P\" & #1 > #2 & #1 > #3 & #2 . #3";
-//		String mult4 = 
-//				"{@type=korap:group, operation=operation:sequence, operands=[" +
-//					// reduce dominance relations "#1 > #2 & #1 > #3" to operand #2 in order to make it accessible for #2 . #3 (the last/outermost relation)  
-//					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
-//						"{@type=korap:group, operation=operation:relation, operands=[" +
-//							// dominance relation #1 > #2 is reduced to #1, for expressing #1 > #3
-//							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//								"{@type=korap:group, operation=operation:relation, operands=[" +
-//									"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//										"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
-//									"]}," +
-//									"{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
-//										"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
-//									"]}" +
-//								"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//							"]}," +
-//							// establish class 2 around P for later reference
-//							"{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
-//								"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
-//							"]}" +
-//						"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//					"]}," +
-//					// refer back to class 2 as second operand
-//					"{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
-//				"], inOrder=true}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(mult4.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//	}	
-//	
-//	@Test
-//	public void testUnaryRelations() throws Exception {
-//		query = "node & #1:tokenarity=2";
-//		String unary1 = 
-//				"{@type=korap:span, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(unary1.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "cnx/cat=\"NP\" & #1:tokenarity=2";
-//		String unary2 = 
-//				"{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(unary2.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "cnx/cat=\"NP\" & #1:root";
-//		String unary3 = 
-//				"{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, root=true}}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(unary3.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//		
-//		query = "cnx/cat=\"NP\" & node & #1>#2 & #1:tokenarity=2";
-//		String unary4 = 
-//					"{@type=korap:group, operation=operation:relation, operands=[" +
-//						"{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}," +
-//						"{@type=korap:span}" +
-//					"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
-//					"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(unary4.replaceAll(" ", ""), map.replaceAll(" ", ""));
-//	}	
-//	
-//	@Test
-//	public void testCommonParent() throws Exception {
-//		query = "cat=\"NP\" & cat=\"VP\" & #1 $ #2";
-//		String cp1 =
-//				"{@type=korap:group, operation=operation:relation, operands=[" +
-//						"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//							"{@type=korap:group, operation=operation:relation, operands=[" +
-//								"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//									"{@type=korap:span}" +
-//								"]}," +
-//								"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
-//							"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//						"]}," +
-//						"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
-//					"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//					"";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(cp1.replaceAll(" ", ""), map.replaceAll(" ", ""));		
-//		
-//		query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 $ #3";
-//		String cp2 =
-//				"{@type=korap:group, operation=operation:relation, operands=[" +
-//					"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//						"{@type=korap:group, operation=operation:relation, operands=[" +
-//							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//								"{@type=korap:group, operation=operation:relation, operands=[" +
-//									"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//										"{@type=korap:span}" +
-//									"]}," +
-//									"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
-//								"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//							"]}," +
-//							"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
-//						"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
-//						"}" +
-//					"]}," +
-//					"{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
-//				"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
-//				"}";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(cp2.replaceAll(" ", ""), map.replaceAll(" ", ""));		
-//		
-//		query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & cat=\"CP\" & #1 $ #2 $ #3 $ #4";
-//		String cp3 =
-//				"{@type=korap:group, operation=operation:relation, operands=[" +
-//					"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//						"{@type=korap:group, operation=operation:relation, operands=[" +
-//							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//								"{@type=korap:group, operation=operation:relation, operands=[" +
-//									"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//										"{@type=korap:group, operation=operation:relation, operands=[" +
-//											"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//												"{@type=korap:span}" +
-//											"]}," +
-//											"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
-//										"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//									"]}," +
-//									"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
-//								"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//							"]}," +
-//							"{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
-//						"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
-//					"]}," +
-//					"{@type=korap:span, layer=cat, key=CP, match=match:eq}" +
-//				"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
-//				"}" +
-//				"";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(cp3.replaceAll(" ", ""), map.replaceAll(" ", ""));		
-//		
-//		query = "cat=\"NP\" & cat=\"VP\" & #1 $* #2";
-//		String cp4 =
-//				"{@type=korap:group, operation=operation:relation, operands=[" +
-//						"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
-//							"{@type=korap:group, operation=operation:relation, operands=[" +
-//								"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
-//									"{@type=korap:span}" +
-//								"]}," +
-//								"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
-//							"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c},boundary={@type=korap:boundary,min=1}}}" +
-//						"]}," +
-//						"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
-//					"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c},boundary={@type=korap:boundary,min=1}}}" +
-//					"";
-//		aqlt = new AqlTree(query);
-//		map = aqlt.getRequestMap().get("query").toString();
-//		assertEquals(cp4.replaceAll(" ", ""), map.replaceAll(" ", ""));		
-//	}
-	
-	/*		
+
+    @Test
+    public void testMultipleMixedOperators() throws Exception {
+        query = "tok=\"Sonne\" & tok=\"Mond\" & tok=\"Sterne\" & #1 > #2 .0,4 #3";
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",         res.at("/query/@type").asText());
+        assertEquals("operation:sequence",  res.at("/query/operation").asText());
+        assertEquals("korap:reference",     res.at("/query/operands/0/@type").asText());
+        assertEquals("operation:focus",     res.at("/query/operands/0/operation").asText());
+        assertEquals(128,                   res.at("/query/operands/0/classRef/0").asInt());
+        assertEquals("korap:group",         res.at("/query/operands/0/operands/0/@type").asText());
+        assertEquals("operation:relation",  res.at("/query/operands/0/operands/0/operation").asText());
+        assertEquals("korap:token",         res.at("/query/operands/0/operands/0/operands/0/@type").asText());
+        assertEquals("Sonne",               res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
+        assertEquals("korap:group",         res.at("/query/operands/0/operands/0/operands/1/@type").asText());
+        assertEquals("operation:class",     res.at("/query/operands/0/operands/0/operands/1/operation").asText());
+        assertEquals(128,                   res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+        assertEquals("Mond",                res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
+        assertEquals("Sterne",              res.at("/query/operands/1/wrap/key").asText());
+        assertEquals("w",                   res.at("/query/distances/0/key").asText());
+        assertEquals(0,                     res.at("/query/distances/0/boundary/min").asInt());
+        assertEquals(4,                     res.at("/query/distances/0/boundary/max").asInt());
+
+        query = "tok=\"Sonne\" & tok=\"Mond\" & #1 > #2 .0,4  tok=\"Sterne\"";
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",         res.at("/query/@type").asText());
+        assertEquals("operation:sequence",  res.at("/query/operation").asText());
+        assertEquals("korap:reference",     res.at("/query/operands/0/@type").asText());
+        assertEquals("operation:focus",     res.at("/query/operands/0/operation").asText());
+        assertEquals(128,                   res.at("/query/operands/0/classRef/0").asInt());
+        assertEquals("korap:group",         res.at("/query/operands/0/operands/0/@type").asText());
+        assertEquals("operation:relation",  res.at("/query/operands/0/operands/0/operation").asText());
+        assertEquals("korap:token",         res.at("/query/operands/0/operands/0/operands/0/@type").asText());
+        assertEquals("Sonne",               res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
+        assertEquals("korap:group",         res.at("/query/operands/0/operands/0/operands/1/@type").asText());
+        assertEquals("operation:class",     res.at("/query/operands/0/operands/0/operands/1/operation").asText());
+        assertEquals(128,                   res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+        assertEquals("Mond",                res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
+        assertEquals("Sterne",              res.at("/query/operands/1/wrap/key").asText());
+        assertEquals("w",                   res.at("/query/distances/0/key").asText());
+        assertEquals(0,                     res.at("/query/distances/0/boundary/min").asInt());
+        assertEquals(4,                     res.at("/query/distances/0/boundary/max").asInt());
+
+        query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 > #3";
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",         res.at("/query/@type").asText());
+        assertEquals("operation:relation",  res.at("/query/operation").asText());
+        assertEquals("korap:reference",     res.at("/query/operands/0/@type").asText());
+        assertEquals("operation:focus",     res.at("/query/operands/0/operation").asText());
+        assertEquals(129,                   res.at("/query/operands/0/classRef/0").asInt());
+        assertEquals("korap:group",         res.at("/query/operands/0/operands/0/@type").asText());
+        assertEquals("operation:relation",  res.at("/query/operands/0/operands/0/operation").asText());
+        assertEquals("korap:reference",     res.at("/query/operands/0/operands/0/operands/0/@type").asText());
+        assertEquals("operation:focus",     res.at("/query/operands/0/operands/0/operands/0/operation").asText());
+        assertEquals(128,                   res.at("/query/operands/0/operands/0/operands/0/classRef/0").asInt());
+        assertEquals("korap:group",         res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
+        assertEquals("operation:relation",  res.at("/query/operands/0/operands/0/operands/0/operands/0/operation").asText());
+        assertEquals("operation:class",     res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operation").asText());
+        assertEquals(128,                   res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut").asInt());
+        assertEquals("korap:span",          res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/@type").asText());
+        assertEquals("NP",                  res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key").asText());
+        assertEquals("korap:group",         res.at("/query/operands/0/operands/0/operands/1/@type").asText());
+        assertEquals("operation:class",     res.at("/query/operands/0/operands/0/operands/1/operation").asText());
+        assertEquals(129,                   res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+        assertEquals("VP",                  res.at("/query/operands/0/operands/0/operands/1/operands/0/key").asText());
+        assertEquals("PP",                  res.at("/query/operands/1/key").asText());
+
+    }
+    @Test
+    public void testMultipleOperatorsWithSameOperands() throws Exception {
+        query = "cat=\"NP\" > cat=\"VP\" & #1 _l_ #2";
+        qs.setQuery(query, "annis");
+        res = mapper.readTree(qs.toJSON());
+        assertEquals("korap:group",         res.at("/query/@type").asText());
+        assertEquals("operation:position",  res.at("/query/operation").asText());
+        assertEquals("frames:startswith",   res.at("/query/frames/0").asText());
+        assertEquals("korap:group",         res.at("/query/operands/0/@type").asText());
+        assertEquals("operation:relation",  res.at("/query/operands/0/operation").asText());
+        // following can't be correct, would need class around and also reference around the relation to be accessed by the position
+        assertEquals("korap:span",          res.at("/query/operands/0/operands/0/@type").asText());
+        assertEquals("NP",                  res.at("/query/operands/0/operands/0/key").asText());
+        assertEquals("VP",                  res.at("/query/operands/0/operands/1/key").asText());
+        assertEquals("korap:reference",     res.at("/query/operands/1/@type").asText());
+
+        String eq2 =
+                "{@type=korap:group, operation=operation:position, frames=[frame:startswith], sharedClasses=[sharedClasses:includes], operands=[" +
+                        "{@type=korap:group, operation=operation:relation, operands=[" +
+                        "{@type=korap:group, operation=operation:class, class=, classOut=129, operands=[" +
+                        "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
+                        "]}," +
+                        "{@type=korap:group, operation=operation:class, class=, classOut=129, operands=[" +
+                        "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
+                        "]}" +
+                        "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}," +
+                        "{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
+                        "]" +
+                        "}"; // ???
+    }
+    //	*/
+    //	@Test
+    //	public void testPositions() throws Exception {
+    //		query = "node & node & #2 _=_ #1";
+    //		String pos1 = 
+    //				"{@type=korap:group, operation=operation:position, frames=[frames:matches], operands=[" +
+    //						"{@type=korap:span}," +
+    //						"{@type=korap:span}" +
+    //				"], frame=frame:matches}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(pos1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "node & node & #2 _i_ #1";
+    //		String pos2 = 
+    //				"{@type=korap:group, operation=operation:position, frames=[frames:contains], operands=[" +
+    //						"{@type=korap:span}," +
+    //						"{@type=korap:span}" +
+    //				"], frame=frame:contains" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(pos2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "node & node & #2 _l_ #1";
+    //		String pos3 = 
+    //				"{@type=korap:group, operation=operation:position, frames=[frames:startswith], operands=[" +
+    //						"{@type=korap:span}," +
+    //						"{@type=korap:span}" +
+    //				"], frame=frame:startswith" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(pos3.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "node & \"Mann\" & #1 _r_ #2";
+    //		String pos4 = 
+    //					"{@type=korap:group, operation=operation:position, frames=[frames:endswith], operands=[" +
+    //						"{@type=korap:span}," +
+    //						"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}" +
+    //						"], frame=frame:endswith" +
+    //					"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(pos4.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "node & \"Mann\" & #2 _r_ #1";
+    //		String pos5 = 
+    //					"{@type=korap:group, operation=operation:position, frames=[frames:endswith], operands=[" +
+    //						"{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mann, match=match:eq}}," +
+    //						"{@type=korap:span}" +
+    //						"], frame=frame:endswith" +
+    //					"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(pos5.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //	}
+    //	
+    //	@Test
+    //	public void testMultiplePredications() throws Exception {
+    //		// a noun before a verb before a preposition
+    //		query = "pos=\"N\" & pos=\"V\" & pos=\"P\" & #1 . #2 & #2 . #3"; 
+    //		String mult1 = 
+    //		"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //			"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //				"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //					"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}," +
+    //					"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //						"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
+    //					"]}" +
+    //				"], inOrder=true}" +
+    //			"]}," +
+    //			"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
+    //		"], inOrder=true}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(mult1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		// a noun before a verb before a preposition
+    //		query = "pos=\"N\" & pos=\"V\" & #1 . #2 & #2 . pos=\"P\""; 
+    //		String mult2 = 
+    //		"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //			"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //				"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //					"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}," +
+    //					"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //						"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
+    //					"]}" +
+    //				"], inOrder=true}" +
+    //			"]}," +
+    //			"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
+    //		"], inOrder=true}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(mult2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //
+    //		query = "pos=\"N\" & pos=\"V\" & pos=\"P\" & #1 > #2 & #1 > #3";
+    //		String mult3 = 
+    //			"{@type=korap:group, operation=operation:relation, operands=[" +
+    //				"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //					"{@type=korap:group, operation=operation:relation, operands=[" +
+    //						"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //							"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" +
+    //						"]}," +
+    //						"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
+    //					"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //				"]}," +
+    //				"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
+    //			"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(mult3.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "cat=\"NP\" & pos=\"V\" & pos=\"P\" & #1 > #2 & #1 > #3 & #2 . #3";
+    //		String mult4 = 
+    //				"{@type=korap:group, operation=operation:sequence, operands=[" +
+    //					// reduce dominance relations "#1 > #2 & #1 > #3" to operand #2 in order to make it accessible for #2 . #3 (the last/outermost relation)  
+    //					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
+    //						"{@type=korap:group, operation=operation:relation, operands=[" +
+    //							// dominance relation #1 > #2 is reduced to #1, for expressing #1 > #3
+    //							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //								"{@type=korap:group, operation=operation:relation, operands=[" +
+    //									"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //										"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
+    //									"]}," +
+    //									"{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
+    //										"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=V, match=match:eq}}" +
+    //									"]}" +
+    //								"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //							"]}," +
+    //							// establish class 2 around P for later reference
+    //							"{@type=korap:group, operation=operation:class, class=130, classOut=130, operands=[" +
+    //								"{@type=korap:token, wrap={@type=korap:term, layer=pos, key=P, match=match:eq}}" +
+    //							"]}" +
+    //						"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //					"]}," +
+    //					// refer back to class 2 as second operand
+    //					"{@type=korap:reference, operation=operation:focus, classRef=[2]}" +
+    //				"], inOrder=true}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(mult4.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //	}	
+    //	
+    //	@Test
+    //	public void testUnaryRelations() throws Exception {
+    //		query = "node & #1:tokenarity=2";
+    //		String unary1 = 
+    //				"{@type=korap:span, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(unary1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "cnx/cat=\"NP\" & #1:tokenarity=2";
+    //		String unary2 = 
+    //				"{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(unary2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "cnx/cat=\"NP\" & #1:root";
+    //		String unary3 = 
+    //				"{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, root=true}}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(unary3.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //		
+    //		query = "cnx/cat=\"NP\" & node & #1>#2 & #1:tokenarity=2";
+    //		String unary4 = 
+    //					"{@type=korap:group, operation=operation:relation, operands=[" +
+    //						"{@type=korap:span, foundry=cnx, layer=cat, key=NP, match=match:eq, attr={@type=korap:term, tokenarity={@type=korap:boundary,min=2,max=2}}}," +
+    //						"{@type=korap:span}" +
+    //					"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
+    //					"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(unary4.replaceAll(" ", ""), map.replaceAll(" ", ""));
+    //	}	
+    //	
+    //	@Test
+    //	public void testCommonParent() throws Exception {
+    //		query = "cat=\"NP\" & cat=\"VP\" & #1 $ #2";
+    //		String cp1 =
+    //				"{@type=korap:group, operation=operation:relation, operands=[" +
+    //						"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //							"{@type=korap:group, operation=operation:relation, operands=[" +
+    //								"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //									"{@type=korap:span}" +
+    //								"]}," +
+    //								"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
+    //							"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //						"]}," +
+    //						"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
+    //					"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //					"";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(cp1.replaceAll(" ", ""), map.replaceAll(" ", ""));		
+    //		
+    //		query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 $ #3";
+    //		String cp2 =
+    //				"{@type=korap:group, operation=operation:relation, operands=[" +
+    //					"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //						"{@type=korap:group, operation=operation:relation, operands=[" +
+    //							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //								"{@type=korap:group, operation=operation:relation, operands=[" +
+    //									"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //										"{@type=korap:span}" +
+    //									"]}," +
+    //									"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
+    //								"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //							"]}," +
+    //							"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
+    //						"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
+    //						"}" +
+    //					"]}," +
+    //					"{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
+    //				"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
+    //				"}";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(cp2.replaceAll(" ", ""), map.replaceAll(" ", ""));		
+    //		
+    //		query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & cat=\"CP\" & #1 $ #2 $ #3 $ #4";
+    //		String cp3 =
+    //				"{@type=korap:group, operation=operation:relation, operands=[" +
+    //					"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //						"{@type=korap:group, operation=operation:relation, operands=[" +
+    //							"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //								"{@type=korap:group, operation=operation:relation, operands=[" +
+    //									"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //										"{@type=korap:group, operation=operation:relation, operands=[" +
+    //											"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //												"{@type=korap:span}" +
+    //											"]}," +
+    //											"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
+    //										"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //									"]}," +
+    //									"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
+    //								"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //							"]}," +
+    //							"{@type=korap:span, layer=cat, key=PP, match=match:eq}" +
+    //						"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
+    //					"]}," +
+    //					"{@type=korap:span, layer=cat, key=CP, match=match:eq}" +
+    //				"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}" +
+    //				"}" +
+    //				"";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(cp3.replaceAll(" ", ""), map.replaceAll(" ", ""));		
+    //		
+    //		query = "cat=\"NP\" & cat=\"VP\" & #1 $* #2";
+    //		String cp4 =
+    //				"{@type=korap:group, operation=operation:relation, operands=[" +
+    //						"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+    //							"{@type=korap:group, operation=operation:relation, operands=[" +
+    //								"{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+    //									"{@type=korap:span}" +
+    //								"]}," +
+    //								"{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
+    //							"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c},boundary={@type=korap:boundary,min=1}}}" +
+    //						"]}," +
+    //						"{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
+    //					"], relation={@type=korap:relation, wrap={@type=korap:term, layer=c},boundary={@type=korap:boundary,min=1}}}" +
+    //					"";
+    //		aqlt = new AqlTree(query);
+    //		map = aqlt.getRequestMap().get("query").toString();
+    //		assertEquals(cp4.replaceAll(" ", ""), map.replaceAll(" ", ""));		
+    //	}
+
+    /*		
 	@Test
 	public void testEqualNotequalValue() throws Exception {
 		query = "cat=\"NP\" & cat=\"VP\" & #1 == #2";
@@ -955,6 +966,7 @@
 		map = aqlt.getRequestMap().get("query").toString();
 		assertEquals(eq1.replaceAll(" ", ""), map.replaceAll(" ", ""));		
 	}
-	*/
-	
+     */
+
 }
+