diff --git a/src/test/java/CollectionQueryTreeTest.java b/src/test/java/CollectionQueryTreeTest.java
index 324a0f8..a367c26 100644
--- a/src/test/java/CollectionQueryTreeTest.java
+++ b/src/test/java/CollectionQueryTreeTest.java
@@ -1,3 +1,4 @@
+import static org.junit.Assert.*;
 import de.ids_mannheim.korap.query.serialize.CollectionQueryBuilder;
 import de.ids_mannheim.korap.query.serialize.CollectionQueryBuilder2;
 import de.ids_mannheim.korap.query.serialize.CollectionQueryTree;
@@ -9,77 +10,225 @@
 
 public class CollectionQueryTreeTest {
 
-    CollectionQueryTree ef;
-    String map;
-    private String query;
+	CollectionQueryTree cqt;
+	String map;
+	private String query;
+	private String expected;
 
-    private boolean equalsQueryContent(String res, String query) throws QueryException {
-        res = res.replaceAll(" ", "");
-        ef = new CollectionQueryTree();
-        ef.process(query);
-        String queryMap = ef.getRequestMap().get("query").toString().replaceAll(" ", "");
-        return res.equals(queryMap);
-    }
+	private boolean equalsQueryContent(String res, String query) throws QueryException {
+		res = res.replaceAll(" ", "");
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		String queryMap = cqt.getRequestMap().get("query").toString().replaceAll(" ", "");
+		return res.equals(queryMap);
+	}
 
-    @Test
-    public void testSimple() throws QueryException {
-        query = "textClass=Sport";
-        String regex1 = "{@type=korap:filter, filter={@type=korap:term, attribute=textClass, key=Sport, match=match:eq}}";
-        ef = new CollectionQueryTree();
-        ef.process(query);
-        map = JsonUtils.toJSON(ef.getRequestMap());
-//		assertEquals(regex1.replaceAll(" ", ""), map.replaceAll(" ", ""));
-        System.out.println("THE QUERY: " + map);
-    }
+	@Test
+	public void testSimple() throws QueryException {
+		query = "textClass=Sport";
+		//      String regex1 = "{@type=korap:filter, filter={@type=korap:doc, attribute=textClass, key=Sport, match=match:eq}}";
+		expected = "{@type=korap:filter, filter={@type=korap:doc, key=textClass, value=Sport, match=match:eq}}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+		query = "textClass!=Sport";
+		//	      String regex1 = "{@type=korap:filter, filter={@type=korap:doc, attribute=textClass, key=Sport, match=match:eq}}";
+		expected = "{@type=korap:filter, filter={@type=korap:doc, key=textClass, value=Sport, match=match:ne}}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+	}
+	
+	@Test
+	public void testTwoConjuncts() throws QueryException {
+		query = "textClass=Sport & year=2014";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:docGroup, relation=relation:and, operands=[" +
+					"{@type=korap:doc, key=textClass, value=Sport, match=match:eq}," +
+					"{@type=korap:doc, key=year, value=2014, match=match:eq}" +
+				"]}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+	}
+	
+	@Test
+	public void testThreeConjuncts() throws QueryException {
+		query = "textClass=Sport & year=2014 & corpusID=WPD";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:docGroup, relation=relation:and, operands=[" +
+					"{@type=korap:doc, key=textClass, value=Sport, match=match:eq}," +
+					"{@type=korap:docGroup, relation=relation:and, operands=[" +
+						"{@type=korap:doc, key=year, value=2014, match=match:eq}," +
+						"{@type=korap:doc, key=corpusID, value=WPD, match=match:eq}" +
+					"]}" +
+				"]}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+	}
+	
+
+	@Test
+	public void testTwoDisjuncts() throws QueryException {
+		query = "textClass=Sport | year=2014";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:docGroup, relation=relation:or, operands=[" +
+					"{@type=korap:doc, key=textClass, value=Sport, match=match:eq}," +
+					"{@type=korap:doc, key=year, value=2014, match=match:eq}" +
+				"]}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+	}
+	
+	@Test
+	public void testThreeDisjuncts() throws QueryException {
+		query = "textClass=Sport | year=2014 | corpusID=WPD";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:docGroup, relation=relation:or, operands=[" +
+					"{@type=korap:doc, key=textClass, value=Sport, match=match:eq}," +
+					"{@type=korap:docGroup, relation=relation:or, operands=[" +
+						"{@type=korap:doc, key=year, value=2014, match=match:eq}," +
+						"{@type=korap:doc, key=corpusID, value=WPD, match=match:eq}" +
+					"]}" +
+				"]}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+	}
 
 
-    @Test
-    public void testComplex() throws QueryException {
-        query = "(textClass=Sport | textClass=ausland) & corpusID=WPD";
-        String regex1 = "{@type=korap:filter, filter={@type=korap:term, attribute=textClass, key=Sport, match=match:eq}}";
-        ef = new CollectionQueryTree();
-        ef.process(query);
-        map = JsonUtils.toJSON(ef.getRequestMap());
-//		assertEquals(regex1.replaceAll(" ", ""), map.replaceAll(" ", ""));
-        System.out.println("THE QUERY 1: " + map);
-    }
+	@Test
+	public void testMixed() throws QueryException {
+		query = "(textClass=Sport | textClass=ausland) & corpusID=WPD";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:docGroup, relation=relation:and, operands=[" +
+					"{@type=korap:docGroup, relation=relation:or, operands=[" +
+						"{@type=korap:doc, key=textClass, value=Sport, match=match:eq}," +
+						"{@type=korap:doc, key=textClass, value=ausland, match=match:eq}" +
+					"]}," +
+					"{@type=korap:doc, key=corpusID, value=WPD, match=match:eq}" +
+				"]}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		query = "(textClass=Sport & textClass=ausland) & corpusID=WPD";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:docGroup, relation=relation:and, operands=[" +
+					"{@type=korap:docGroup, relation=relation:and, operands=[" +
+						"{@type=korap:doc, key=textClass, value=Sport, match=match:eq}," +
+						"{@type=korap:doc, key=textClass, value=ausland, match=match:eq}" +
+					"]}," +
+					"{@type=korap:doc, key=corpusID, value=WPD, match=match:eq}" +
+				"]}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		query = "(textClass=Sport & textClass=ausland) | (corpusID=WPD & author=White)";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:docGroup, relation=relation:or, operands=[" +
+					"{@type=korap:docGroup, relation=relation:and, operands=[" +
+						"{@type=korap:doc, key=textClass, value=Sport, match=match:eq}," +
+						"{@type=korap:doc, key=textClass, value=ausland, match=match:eq}" +
+					"]}," +
+					"{@type=korap:docGroup, relation=relation:and, operands=[" +
+						"{@type=korap:doc, key=corpusID, value=WPD, match=match:eq}," +
+						"{@type=korap:doc, key=author, value=White, match=match:eq}" +
+					"]}" +
+				"]}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		query = "(textClass=Sport & textClass=ausland) | (corpusID=WPD & author=White & year=2010)";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:docGroup, relation=relation:or, operands=[" +
+					"{@type=korap:docGroup, relation=relation:and, operands=[" +
+						"{@type=korap:doc, key=textClass, value=Sport, match=match:eq}," +
+						"{@type=korap:doc, key=textClass, value=ausland, match=match:eq}" +
+					"]}," +
+					"{@type=korap:docGroup, relation=relation:and, operands=[" +
+						"{@type=korap:doc, key=corpusID, value=WPD, match=match:eq}," +
+						"{@type=korap:docGroup, relation=relation:and, operands=[" +
+							"{@type=korap:doc, key=author, value=White, match=match:eq}," +
+							"{@type=korap:doc, key=year, value=2010, match=match:eq}" +
+						"]}" +
+					"]}" +
+				"]}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+	}
 
-    @Test
-    public void testBuilder() throws QueryException {
-        CollectionQueryBuilder2 builder = new CollectionQueryBuilder2();
-        builder.setQuery("(textClass=Sport | textClass=ausland) & corpusID=WPD");
-        System.out.println("BUILDER RESULT: " + builder.toJSON());
-    }
+	@Test
+	public void testDate() throws QueryException {
+		// search for pubDate between 1990 and 2010!
+		query = "1990<pubDate<2010";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:docGroup, relation=relation:and, operands=[" +
+					"{@type=korap:doc, key=pubDate, value=1990, match=match:gt}," +
+					"{@type=korap:doc, key=pubDate, value=2010, match=match:lt}" +
+				"]}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		query = "pubDate>=1990";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:doc, key=pubDate, value=1990, match=match:geq}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+	}
 
-//    @Test
-    public void testSimpleBuilder() {
-        CollectionQueryBuilder b = new CollectionQueryBuilder();
-        b.addMetaFilter("corpusID", "WPD");
-        b.addMetaFilter("textClass", "wissenschaft");
-        b.setFilterAttributeRelation(Relation.AND);
-        System.out.println("SIMPLE BUILDER RESULT: " + b.toCollections());
-    }
-
-    // old builder pubDate query
-//    @Test
-    public void testDateQuery() {
-        CollectionQueryBuilder b = new CollectionQueryBuilder();
-        String query = "pubDate=>" + TimeUtils.getNow().getMillis();
-        query = query + " AND pubDate=<" + TimeUtils.getNow().getMillis();
-        b.addMetaFilterQuery(query);
-        b.setFilterAttributeRelation(Relation.AND);
-        System.out.println("FINAL RESOURCE: " + b.toCollections());
-    }
-
-    @Test
-    public void testDateNewQuery() throws QueryException {
-        // search for pubDate between 1990 and 2010!
-        String query = "1990<pubDate<2010 & genre=Sport";
-        CollectionQueryBuilder2 q = new CollectionQueryBuilder2();
-        q.setQuery(query);
-        System.out.println("DATE QUERY RESULT: " + q.toJSON());
-    }
-
+	@Test
+	public void testRegex() throws QueryException {
+		query = "author=/Go.*he/";
+		expected = 
+			"{@type=korap:filter, filter=" +
+				"{@type=korap:doc, key=author, value=Go.*he, type=type:regex, match=match:eq}" +
+			"}";
+		cqt = new CollectionQueryTree();
+		cqt.process(query);
+		map = cqt.getRequestMap().toString();
+		assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+	}
 
 }
 
