text rewrite tests
diff --git a/src/test/java/CollectionQueryBuilderTest.java b/src/test/java/CollectionQueryBuilderTest.java
index 407608d..f895962 100644
--- a/src/test/java/CollectionQueryBuilderTest.java
+++ b/src/test/java/CollectionQueryBuilderTest.java
@@ -38,7 +38,8 @@
         assertEquals("koral:docGroup", node.at("/collection/@type").asText());
         assertEquals("operation:and", node.at("/collection/operation").asText());
 
-        assertEquals("corpusSigle", node.at("/collection/operands/0/key").asText());
+        assertEquals("corpusSigle", node.at("/collection/operands/0/key")
+                .asText());
         assertEquals("textClass", node.at("/collection/operands/1/key")
                 .asText());
     }
@@ -92,11 +93,14 @@
                 .asText());
         assertEquals(2, node.at("/collection/operands").size());
         assertEquals(2, node.at("/collection/operands/0/operands").size());
-        assertEquals(2, node.at("/collection/operands/0/operands/0/operands").size());
+        assertEquals(2, node.at("/collection/operands/0/operands/0/operands")
+                .size());
 
         assertEquals("operation:and", node.at("/collection/operation").asText());
-        assertEquals("operation:or", node.at("/collection/operands/0/operation").asText());
-        assertEquals("operation:and", node.at("/collection/operands/0/operands/0/operation").asText());
+        assertEquals("operation:or", node
+                .at("/collection/operands/0/operation").asText());
+        assertEquals("operation:and",
+                node.at("/collection/operands/0/operands/0/operation").asText());
         assertEquals("WPD", node.at("/collection/operands/1/value").asText());
     }
 
@@ -152,7 +156,8 @@
         assertEquals("koral:doc", res.at("/collection/operands/1/@type")
                 .asText());
         assertEquals("WPD", res.at("/collection/operands/0/value").asText());
-        assertEquals("corpusSigle", res.at("/collection/operands/0/key").asText());
+        assertEquals("corpusSigle", res.at("/collection/operands/0/key")
+                .asText());
 
         // check also that query is still there
         assertEquals("koral:token", res.at("/query/@type").asText());
@@ -182,8 +187,9 @@
         assertEquals(base.at("/collection/operands/0/operands").size(), 2);
     }
 
+
     @Test
-    public void testNodeMergeWithBase() {
+    public void testNodeMergeWithBase () {
         String coll = "corpusSigle=WPD";
         String query = "[base=Haus]";
         QuerySerializer check = new QuerySerializer();
@@ -209,8 +215,9 @@
 
     }
 
+
     @Test
-    public void testAddOROperator() {
+    public void testAddOROperator () {
         String coll = "corpusSigle=WPD";
         String query = "[base=Haus]";
         QuerySerializer check = new QuerySerializer();
@@ -227,8 +234,9 @@
         assertEquals(2, node.at("/collection/operands/1/operands").size());
     }
 
+
     @Test
-    public void testAddANDOperator() {
+    public void testAddANDOperator () {
         String coll = "corpusSigle=WPD";
         String query = "[base=Haus]";
         QuerySerializer check = new QuerySerializer();
@@ -245,8 +253,9 @@
         assertEquals(2, node.at("/collection/operands/1/operands").size());
     }
 
+
     @Test
-    public void testAddDefaultOperator() {
+    public void testAddDefaultOperator () {
         String coll = "corpusSigle=WPD";
         String query = "[base=Haus]";
         QuerySerializer check = new QuerySerializer();
@@ -263,9 +272,10 @@
         assertEquals(2, node.at("/collection/operands/1/operands").size());
     }
 
+
     @Test
     @Ignore
-    public void testMergeOperator() {
+    public void testMergeOperator () {
         String coll = "corpusSigle=WPD";
         String query = "[base=Haus]";
         QuerySerializer check = new QuerySerializer();
diff --git a/src/test/java/KoralNodeTest.java b/src/test/java/KoralNodeTest.java
index d8f5ab1..6418ee1 100644
--- a/src/test/java/KoralNodeTest.java
+++ b/src/test/java/KoralNodeTest.java
@@ -7,6 +7,7 @@
  * @author hanl
  * @date 21/10/2015
  */
+// todo: complete tests
 public class KoralNodeTest {
 
     // todo: 21.10.15 --> e.g. injection does not tell you if an entire node was injected, or just a value!
@@ -25,7 +26,7 @@
         ObjectNode node = JsonUtils.createObjectNode();
         node.put("value_1", "setting_1");
         KoralNode knode = KoralNode.wrapNode(node);
-        knode.remove("value_1");
+        knode.remove("value_1", null);
         System.out.println(knode.rawNode().toString());
     }
 
@@ -35,7 +36,7 @@
         ObjectNode node = JsonUtils.createObjectNode();
         node.put("value_1", "setting_1");
         KoralNode knode = KoralNode.wrapNode(node);
-        knode.replace("value_1", "settings_2");
+        knode.replace("value_1", "settings_2", null);
         System.out.println(knode.rawNode().toString());
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
index d655713..8e67a30 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
@@ -5,13 +5,10 @@
 import de.ids_mannheim.korap.config.KustvaktConfiguration;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.query.serialize.QuerySerializer;
-import de.ids_mannheim.korap.resources.Corpus;
-import de.ids_mannheim.korap.security.ac.ResourceFinder;
 import de.ids_mannheim.korap.user.User;
 import de.ids_mannheim.korap.utils.JsonUtils;
 import org.junit.Test;
 
-import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -58,14 +55,15 @@
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("textClass=politik & corpusSigle=WPD");
         String result = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(result,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                 User.UserFactory.getUser("test_user")));
         assertNotNull(node);
         assertEquals(1, node.at("/collection/operands").size());
     }
 
+
     @Test
-    public void testCollectionNodeDeletionNotification() {
+    public void testCollectionNodeDeletionNotification () {
 
     }
 
@@ -80,13 +78,15 @@
         s.setCollection("corpusSigle=BRZ13 & corpusSigle=WPD");
         String result = s.toJSON();
         try {
-            JsonNode node = JsonUtils.readTree(handler.process(result,
+            JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                     User.UserFactory.getUser("test_user")));
             System.out.println(node);
             assertNotNull(node);
             assertEquals(0, node.at("/collection/operands").size());
-            assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
-        } catch ( Exception e) {
+            assertEquals("koral:rewrite",
+                    node.at("/collection/rewrites/0/@type").asText());
+        }
+        catch (Exception e) {
             e.printStackTrace();
         }
     }
@@ -101,7 +101,7 @@
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ13 & textClass=Wissenschaft) & corpusSigle=WPD");
         String result = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(result,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                 User.UserFactory.getUser("test_user")));
 
         assertNotNull(node);
@@ -109,7 +109,8 @@
                 .asText());
         assertEquals("textClass",
                 node.at("/collection/operands/0/operands/0/key").asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
@@ -119,13 +120,13 @@
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
-        handler.add(CollectionCleanupFilter.class);
+        handler.add(CollectionCleanRewrite.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ13 & corpusSigle=WPD) & textClass=Wissenschaft & textClass=Sport");
         String result = s.toJSON();
 
-        JsonNode node = JsonUtils.readTree(handler.process(result,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                 User.UserFactory.getUser("test_user")));
 
 
@@ -137,7 +138,8 @@
                 .asText());
         assertEquals("textClass", node.at("/collection/operands/1/key")
                 .asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
@@ -146,18 +148,19 @@
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
-        handler.add(CollectionCleanupFilter.class);
+        handler.add(CollectionCleanRewrite.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ13 & textClass=wissenschaft)");
         String result = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(result,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                 User.UserFactory.getUser("test_user")));
         assertNotNull(node);
         assertEquals("koral:doc", node.at("/collection/@type").asText());
         assertEquals("textClass", node.at("/collection/key").asText());
         assertEquals("wissenschaft", node.at("/collection/value").asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
@@ -166,18 +169,19 @@
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
-        handler.add(CollectionCleanupFilter.class);
+        handler.add(CollectionCleanRewrite.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ13 & corpusSigle=WPD) & textClass=Wissenschaft");
         String result = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(result,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                 User.UserFactory.getUser("test_user")));
 
         assertNotNull(node);
         assertEquals("koral:doc", node.at("/collection/@type").asText());
         assertEquals("textClass", node.at("/collection/key").asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
@@ -186,12 +190,12 @@
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
-        handler.add(CollectionCleanupFilter.class);
+        handler.add(CollectionCleanRewrite.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(docID=random & textClass=Wissenschaft) & corpusSigle=WPD");
         String org = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(org,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(org,
                 User.UserFactory.getUser("test_user")));
         System.out.println(node);
         assertNotNull(node);
@@ -201,7 +205,8 @@
                 .asText());
         assertEquals("koral:doc", node.at("/collection/operands/1/@type")
                 .asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
@@ -214,12 +219,16 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         String org = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(org,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(org,
                 User.UserFactory.getUser("test_user")));
         assertNotNull(node);
-        assertEquals("corpusSigle", node.at("/collection/operands/0/key").asText());
-        assertEquals("corpusSigle", node.at("/collection/operands/1/key").asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("corpusSigle", node.at("/collection/operands/0/key")
+                .asText());
+        assertEquals("corpusSigle", node.at("/collection/operands/1/key")
+                .asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
+        System.out.println("NODE " + node);
     }
 
 
@@ -230,22 +239,25 @@
         handler.insertBeans(helper().getContext());
         handler.add(PublicCollection.class);
 
-            QuerySerializer s = new QuerySerializer();
-            s.setQuery(simple_add_query, "poliqarp");
-            s.setCollection("(docSigle=WPD_AAA & textClass=wissenschaft)");
-            String org = s.toJSON();
-            JsonNode node = JsonUtils.readTree(handler.process(org,
-                    User.UserFactory.getUser("test_user")));
-            assertNotNull(node);
-            assertEquals(2, node.at("/collection/operands").size());
-            assertEquals("corpusSigle", node.at("/collection/operands/1/operands/0/key").asText());
-            assertEquals("corpusSigle", node.at("/collection/operands/1/operands/1/key").asText());
-            assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        QuerySerializer s = new QuerySerializer();
+        s.setQuery(simple_add_query, "poliqarp");
+        s.setCollection("(docSigle=WPD_AAA & textClass=wissenschaft)");
+        String org = s.toJSON();
+        JsonNode node = JsonUtils.readTree(handler.processQuery(org,
+                User.UserFactory.getUser("test_user")));
+        assertNotNull(node);
+        assertEquals(2, node.at("/collection/operands").size());
+        assertEquals("corpusSigle",
+                node.at("/collection/operands/1/operands/0/key").asText());
+        assertEquals("corpusSigle",
+                node.at("/collection/operands/1/operands/1/key").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
     @Test
-    public void testRemoveCorpusFromDifferentGroups() {
+    public void testRemoveCorpusFromDifferentGroups () {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
@@ -253,7 +265,7 @@
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ14 & textClass=wissenschaft) | (corpusSigle=AZPR | textClass=freizeit)");
         String org = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(org,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(org,
                 User.UserFactory.getUser("test_user")));
         assertNotNull(node);
         assertEquals("koral:docGroup", node.at("/collection/@type").asText());
@@ -264,34 +276,43 @@
                 .asText());
         assertEquals(1, node.at("/collection/operands/0/operands").size());
         assertEquals(1, node.at("/collection/operands/1/operands").size());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
+
     @Test
-    public void testRemoveOneCorpusAndMoveDocFromTwoGroups() {
+    public void testRemoveOneCorpusAndMoveDocFromTwoGroups () {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
         // todo: use this collection query also to test clean up filter! after reduction of corpusSigle (wiss | freizeit)!
-        handler.add(CollectionCleanupFilter.class);
+        handler.add(CollectionCleanRewrite.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ14 & textClass=wissenschaft) | (corpusSigle=AZPR | textClass=freizeit)");
         String org = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(org,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(org,
                 User.UserFactory.getUser("test_user")));
         assertNotNull(node);
         assertEquals("koral:docGroup", node.at("/collection/@type").asText());
         assertEquals(2, node.at("/collection/operands").size());
         assertEquals("koral:doc", node.at("/collection/operands/0/@type")
                 .asText());
-        assertEquals("koral:doc", node.at("/collection/operands/0/@type").asText());
-        assertEquals("textClass", node.at("/collection/operands/0/key").asText());
-        assertEquals("wissenschaft", node.at("/collection/operands/0/value").asText());
-        assertEquals("koral:doc", node.at("/collection/operands/1/@type").asText());
-        assertEquals("textClass", node.at("/collection/operands/1/key").asText());
-        assertEquals("freizeit", node.at("/collection/operands/1/value").asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:doc", node.at("/collection/operands/0/@type")
+                .asText());
+        assertEquals("textClass", node.at("/collection/operands/0/key")
+                .asText());
+        assertEquals("wissenschaft", node.at("/collection/operands/0/value")
+                .asText());
+        assertEquals("koral:doc", node.at("/collection/operands/1/@type")
+                .asText());
+        assertEquals("textClass", node.at("/collection/operands/1/key")
+                .asText());
+        assertEquals("freizeit", node.at("/collection/operands/1/value")
+                .asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
index 90bcc86..8c0f1f0 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
@@ -63,7 +63,7 @@
         processor.add(FoundryInject.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[base=Haus]", "poliqarp");
-        String result = processor.process(s.toJSON(), null);
+        String result = processor.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(result);
         assertNotNull(node);
         assertFalse(node.at("/query/wrap/foundry").isMissingNode());
@@ -87,7 +87,7 @@
         handler.insertBeans(helper().getContext());
         s.setQuery("[pos=ADJA]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String result = handler.process(s.toJSON(), null);
+        String result = handler.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(result);
 
         assertNotNull(node);
@@ -112,7 +112,7 @@
         handler.add(FoundryInject.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[pos=ADJA]", "poliqarp");
-        String result = handler.process(s.toJSON(), user);
+        String result = handler.processQuery(s.toJSON(), user);
         JsonNode node = JsonUtils.readTree(result);
 
         UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
@@ -142,7 +142,7 @@
         handler.add(FoundryInject.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[base=Haus]", "poliqarp");
-        String result = handler.process(s.toJSON(), user);
+        String result = handler.processQuery(s.toJSON(), user);
         JsonNode node = JsonUtils.readTree(result);
 
         UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
@@ -170,7 +170,7 @@
         handler.insertBeans(helper().getContext());
         s.setQuery("[orth=laufe/i & base!=Lauf]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String result = handler.process(s.toJSON(), null);
+        String result = handler.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(result);
 
         assertNotNull(node);
@@ -189,7 +189,7 @@
         handler.insertBeans(helper().getContext());
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String result = handler.process(s.toJSON(), null);
+        String result = handler.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(result);
 
         assertNotNull(node);
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
index 909f9c9..69e8ea7 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
@@ -25,7 +25,7 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery(query, "poliqarp");
 
-        String value = handler.process(s.toJSON(), null);
+        String value = handler.processQuery(s.toJSON(), null);
         JsonNode result = JsonUtils.readTree(value);
 
         assertNotNull(result);
@@ -41,7 +41,7 @@
 
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[base=Haus]", "poliqarp");
-        String result = handler.process(s.toJSON(), null);
+        String result = handler.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(result);
         assertNotNull(node);
         assertFalse(node.at("/query/wrap").isMissingNode());
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/PostRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/PostRewriteTest.java
deleted file mode 100644
index ef0c10a..0000000
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/PostRewriteTest.java
+++ /dev/null
@@ -1,518 +0,0 @@
-package de.ids_mannheim.korap.resource.rewrite;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.DocumentDao;
-import de.ids_mannheim.korap.resources.Document;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import net.sf.ehcache.CacheManager;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * @author hanl
- * @date 12/11/2015
- */
-// todo: logging!
-public class PostRewriteTest extends BeanConfigTest {
-
-    @Override
-    public void initMethod () throws KustvaktException {
-
-    }
-
-
-    // otherwise cache will maintain values not relevant for other tests
-    @Before
-    public void before () {
-        CacheManager.getInstance().getCache("documents").removeAll();
-        DocumentDao dao = new DocumentDao(helper().getContext()
-                .getPersistenceClient());
-        dao.truncate();
-    }
-
-
-    @Test
-    public void testPostRewriteNothingToDo () throws KustvaktException {
-        RewriteHandler ha = new RewriteHandler();
-        ha.insertBeans(helper().getContext());
-        assertEquals("Handler could not be added to rewriter instance!", true,
-                ha.add(DocMatchRewrite.class));
-
-        DocumentDao dao = new DocumentDao(helper().getContext()
-                .getPersistenceClient());
-        try {
-            Document d = dao.findbyId("BRZ13_APR.00014", null);
-            assertNull(d);
-            String v = ha.process(RESULT, null);
-            assertEquals("results do not match", JsonUtils.readTree(RESULT),
-                    JsonUtils.readTree(v));
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-
-    @Test
-    public void testPostRewriteRemoveDoc () {
-        DocumentDao dao = new DocumentDao(helper().getContext()
-                .getPersistenceClient());
-
-        Document doc = new Document("BRZ13_APR.00014");
-        doc.setDisabled(true);
-        try {
-            dao.storeResource(doc, null);
-        }
-        catch (KustvaktException e) {
-            return;
-        }
-
-        RewriteHandler ha = new RewriteHandler();
-        ha.insertBeans(helper().getContext());
-        assertEquals("Handler could not be added to rewriter instance!", true,
-                ha.add(DocMatchRewrite.class));
-
-        String v = ha.process(RESULT, null);
-
-        JsonNode node = JsonUtils.readTree(v);
-
-        assertNotEquals("Wrong DocID", "BRZ13_APR.00014",
-                node.at("/matches/1/docID"));
-
-        try {
-            dao.deleteResource(doc.getPersistentID(), null);
-            Document d = dao.findbyId(doc.getPersistentID(), null);
-            if (d != null)
-                System.out.println("IS SUPPOSED TO BE NULL! " + d);
-        }
-        catch (KustvaktException e) {
-            e.printStackTrace();
-            return;
-        }
-
-    }
-
-
-    @Test
-    public void testPath () {
-        String v = "{\n" + "    \"meta\": {\n" + "        \"count\": 25,\n"
-                + "        \"startIndex\": 0,\n"
-                + "        \"timeout\": 120000,\n" + "        \"context\": {\n"
-                + "            \"left\": [\n" + "                \"token\",\n"
-                + "                6\n" + "            ],\n"
-                + "            \"right\": [\n" + "                \"token\",\n"
-                + "                6\n" + "            ]\n" + "        }}}";
-        JsonNode n = JsonUtils.readTree(v);
-
-    }
-
-    private static final String RESULT = "{\n"
-            + "    \"meta\": {\n"
-            + "        \"count\": 25,\n"
-            + "        \"startIndex\": 0,\n"
-            + "        \"timeout\": 120000,\n"
-            + "        \"context\": {\n"
-            + "            \"left\": [\n"
-            + "                \"token\",\n"
-            + "                6\n"
-            + "            ],\n"
-            + "            \"right\": [\n"
-            + "                \"token\",\n"
-            + "                6\n"
-            + "            ]\n"
-            + "        },\n"
-            + "        \"fields\": [\n"
-            + "            \"textSigle\",\n"
-            + "            \"author\",\n"
-            + "            \"docSigle\",\n"
-            + "            \"title\",\n"
-            + "            \"pubDate\",\n"
-            + "            \"UID\",\n"
-            + "            \"corpusID\",\n"
-            + "            \"textClass\",\n"
-            + "            \"subTitle\",\n"
-            + "            \"layerInfos\",\n"
-            + "            \"ID\",\n"
-            + "            \"pubPlace\",\n"
-            + "            \"corpusSigle\"\n"
-            + "        ],\n"
-            + "        \"version\": \"unknown\",\n"
-            + "        \"benchmark\": \"0.204314141 s\",\n"
-            + "        \"totalResults\": 1755,\n"
-            + "        \"serialQuery\": \"tokens:tt/l:Wort\",\n"
-            + "        \"itemsPerPage\": 25\n"
-            + "    },\n"
-            + "    \"query\": {\n"
-            + "        \"@type\": \"koral:token\",\n"
-            + "        \"wrap\": {\n"
-            + "            \"@type\": \"koral:term\",\n"
-            + "            \"key\": \"Wort\",\n"
-            + "            \"layer\": \"lemma\",\n"
-            + "            \"match\": \"match:eq\",\n"
-            + "            \"foundry\": \"tt\",\n"
-            + "            \"rewrites\": [\n"
-            + "                {\n"
-            + "                    \"@type\": \"koral:rewrite\",\n"
-            + "                    \"src\": \"Kustvakt\",\n"
-            + "                    \"operation\": \"operation:injection\"\n"
-            + "                }\n"
-            + "            ]\n"
-            + "        }\n"
-            + "    },\n"
-            + "    \"matches\": [\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"staat-gesellschaft familie-geschlecht\",\n"
-            + "            \"title\": \"Sexueller Missbrauch –„Das schreiende Kind steckt noch tief in mir“\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>in ihrer Stimme schwingt bei diesem </span><mark>Wort</mark><span class=\\\"context-right\\\"> Sarkasmus mit. Bis man einen passenden<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00001-p454-455\",\n"
-            + "            \"docID\": \"BRZ13_APR.00001\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"freizeit-unterhaltung reisen\",\n"
-            + "            \"title\": \"Leben dick und prall\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>der DLRG, ausgelassene Partys und markige </span><mark>Worte</mark><span class=\\\"context-right\\\"> des Dompredigers: „Ostern ist kein goethischer<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00014-p96-97\",\n"
-            + "            \"docID\": \"BRZ13_APR.00014\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"staat-gesellschaft biographien-interviews kultur musik\",\n"
-            + "            \"title\": \"So wird es gemacht:\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>derfehlende Buchstabe.Gelingt es dir,das </span><mark>Wort</mark><span class=\\\"context-right\\\"> vervollständigen? Tipp: Probiere auch mal rückwärts<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00055-p19-20\",\n"
-            + "            \"docID\": \"BRZ13_APR.00055\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik ausland\",\n"
-            + "            \"title\": \"Südkorea droht mit Angriffen – USA rüsten auf\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>der Stunde. „Aus einem Krieg der </span><mark>Worte</mark><span class=\\\"context-right\\\"> darf kein echter Krieg werden“, sagte<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00076-p238-239\",\n"
-            + "            \"docID\": \"BRZ13_APR.00076\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland freizeit-unterhaltung reisen\",\n"
-            + "            \"title\": \"Dauercamper kämpfen für ihren Platz\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>„Initiative Campingplatz Räbke“. „Als ich das </span><mark>Wort</mark><span class=\\\"context-right\\\"> Schließung gelesen habe, war ich richtig<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00200-p255-256\",\n"
-            + "            \"docID\": \"BRZ13_APR.00200\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"freizeit-unterhaltung reisen\",\n"
-            + "            \"title\": \"Neue Aktionen lockten Besucher\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>Jan Waldheim (CWG) unter den aufmunternden </span><mark>Worten</mark><span class=\\\"context-right\\\"> eines augenzwinkernden Axel Schnalke („Ein bisschen<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00210-p142-143\",\n"
-            + "            \"docID\": \"BRZ13_APR.00210\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"kultur musik\",\n"
-            + "            \"title\": \"Travestie – Helden in Strumpfhosen\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>trotzdem nicht. Selten wurden so viele </span><mark>Worte</mark><span class=\\\"context-right\\\">, die der Autor hier lieber verschweigt<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00253-p166-167\",\n"
-            + "            \"docID\": \"BRZ13_APR.00253\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"kultur musik\",\n"
-            + "            \"title\": \"Travestie – Helden in Strumpfhosen\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>zudem nicht immer nur bei den </span><mark>Worten</mark><span class=\\\"context-right\\\"> geblieben) und dabei gleichzeitig soviel Charme<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00253-p191-192\",\n"
-            + "            \"docID\": \"BRZ13_APR.00253\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"kultur musik\",\n"
-            + "            \"title\": \"Travestie – Helden in Strumpfhosen\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>bedeutet Travestie sich zu verkleiden, das </span><mark>Wort</mark><span class=\\\"context-right\\\"> stammt aus dem Französischen. Traditionell belegten<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00253-p371-372\",\n"
-            + "            \"docID\": \"BRZ13_APR.00253\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"VfL kommt nicht vom Fleck\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>am internationalen Geschäft berechtigt. Mit anderen </span><mark>Worten</mark><span class=\\\"context-right\\\">: Die „Wölfe“ stecken im grauen Mittelmaß<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00260-p93-94\",\n"
-            + "            \"docID\": \"BRZ13_APR.00260\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"Mensch, Mayer! Super Tor\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>bekommst, ist das unbezahlbar – ein Bonus.“ </span><mark>Worte</mark><span class=\\\"context-right\\\">, die dem Torschützen weiteres Selbstvertrauen geben<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00275-p271-272\",\n"
-            + "            \"docID\": \"BRZ13_APR.00275\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"Nur Gerücht? KHL-Klub will „Dshuni“\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>und hakt das Thema ab.cb Kein </span><mark>Wort</mark><span class=\\\"context-right\\\"> zum Interesse aus Astana: Daniar Dshunussow.Foto<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00277-p163-164\",\n"
-            + "            \"docID\": \"BRZ13_APR.00277\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"staat-gesellschaft biographien-interviews\",\n"
-            + "            \"title\": \"Das Leben ist nicht auf diese Erde beschränkt\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>1. Korinther 1,18 denken: Denn das </span><mark>Wort</mark><span class=\\\"context-right\\\"> vom Kreuz ist eine Torheit denen<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00520-p32-33\",\n"
-            + "            \"docID\": \"BRZ13_APR.00520\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-03\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"Allofs und Hecking knöpfensich die VfL-Profis vor\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>für die Profis am Dienstag klare </span><mark>Worte</mark><span class=\\\"context-right\\\"> vom Führungsduo. Von Thorsten Grunow Wolfsburg<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00557-p17-18\",\n"
-            + "            \"docID\": \"BRZ13_APR.00557\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-03\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"Allofs und Hecking knöpfensich die VfL-Profis vor\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>Minuten setzte es am Dienstagnachmittag klare </span><mark>Worte</mark><span class=\\\"context-right\\\"> für die kickende Belegschaft, die durchaus<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00557-p60-61\",\n"
-            + "            \"docID\": \"BRZ13_APR.00557\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-03\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"Allofs und Hecking knöpfensich die VfL-Profis vor\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>Manager ist überzeugt, dass die klaren </span><mark>Worte</mark><span class=\\\"context-right\\\"> auf fruchtbaren Boden gefallen sind. „Ich<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00557-p235-236\",\n"
-            + "            \"docID\": \"BRZ13_APR.00557\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-03\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland politik ausland\",\n"
-            + "            \"title\": \"Zeitungsartikelzufällig deponiert?\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>erspart“, lautete die Schlagzeile – wobei das </span><mark>Wort</mark><span class=\\\"context-right\\\"> „erspart“ abgeschnitten war. Ein plumper Versuch<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07616-p31-32\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07616\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"„Philipp Rösler wackelt nicht“\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>Vizekanzler bei all dem Jubel zu </span><mark>Wort</mark><span class=\\\"context-right\\\"> kommt. „Ein großartiger Tag“, sagt er<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07617-p177-178\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07617\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"freizeit-unterhaltung reisen\",\n"
-            + "            \"title\": \"Lanz gibt den charmanten, zurückhaltenden Gastgeber\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>er, als seine Assistentin ihm ins </span><mark>Wort</mark><span class=\\\"context-right\\\"> fiel. Dennoch holte das ungleiche Duo<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07621-p261-262\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07621\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"Mundlos denkt über Rücktritt nach\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>räumte selbst ein, wie sarkastisch diese </span><mark>Worte</mark><span class=\\\"context-right\\\"> nach einer solchen Wahlnacht klingen mussten<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07694-p192-193\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07694\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"BraunschweigGold – Hannover Blech\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>im Volksfreundhaus hört man kein schlechtes </span><mark>Wort</mark><span class=\\\"context-right\\\"> über den Kanzlerkandidaten Peer Steinbrück – und<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07695-p169-170\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07695\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"BraunschweigGold – Hannover Blech\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>Volksfreundhaus merklich steigen. Hier hat das </span><mark>Wort</mark><span class=\\\"context-right\\\"> von der Wahlparty bei Bier, Bockwurst<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07695-p266-267\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07695\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"staat-gesellschaft kirche\",\n"
-            + "            \"title\": \"Fernsehen überträgt Gottesdienst\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>schon mal von der Sendung „Das </span><mark>Wort</mark><span class=\\\"context-right\\\"> zum Sonntag“ gehört. Das sind Predigten<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07840-p37-38\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07840\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"Wahlkrimi im Ratssaal\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>ihre Konkurrentin Glosemeyer hatte sie warme </span><mark>Worte</mark><span class=\\\"context-right\\\"> übrig. „Für den ersten Anlauf eine<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07848-p147-148\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07848\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"Warme Worte nach eiskaltem Wahlkampf\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\">Warme </span><mark>Worte</mark><span class=\\\"context-right\\\"> nach eiskaltem Wahlkampf Die SPD feierte<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07850-p1-2\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07850\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n" + "        }\n"
-            + "    ]\n" + "}";
-
-}
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
index 15df2a9..112282c 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
@@ -39,7 +39,7 @@
         handler.insertBeans(helper().getContext());
         assertTrue(handler.add(FoundryInject.class));
         assertTrue(handler.add(DocMatchRewrite.class));
-        assertTrue(handler.add(CollectionCleanupFilter.class));
+        assertTrue(handler.add(CollectionCleanRewrite.class));
         assertTrue(handler.add(IdWriter.class));
     }
 
@@ -51,7 +51,7 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        handler.process(s.toJSON(), null);
+        handler.processQuery(s.toJSON(), null);
     }
 
 
@@ -62,7 +62,7 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String res = handler.process(s.toJSON(), null);
+        String res = handler.processQuery(s.toJSON(), null);
         assertNotNull(res);
     }
 
@@ -74,7 +74,7 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String res = handler.process(s.toJSON(), null);
+        String res = handler.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(res);
         assertNotNull(node);
 
@@ -93,7 +93,7 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String res = handler.process(s.toJSON(), helper().getUser());
+        String res = handler.processQuery(s.toJSON(), helper().getUser());
         JsonNode node = JsonUtils.readTree(res);
         assertNotNull(node);
         assertEquals("tt_test",
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
index d7e33b9..d24cad1 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
@@ -14,6 +14,7 @@
 import org.junit.Test;
 
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 /**
  * @author hanl
@@ -48,14 +49,6 @@
     }
 
 
-    //    @AfterClass
-    //    public static void drop() throws KustvaktException {
-    //        assert handler != null;
-    //        handler.removeClient(info, helper().getUser());
-    //        helper().dropUser();
-    //        BeansFactory.closeApplication();
-    //    }
-
     @Test
     public void testStoreAuthorizationCodeThrowsNoException ()
             throws KustvaktException {
@@ -89,7 +82,7 @@
         assertNotNull("context is null", ctx);
 
         AuthCodeInfo c2 = handler.getAuthorization(codeInfo.getCode());
-        Assert.assertNull("clearing authorization failed", c2);
+        assertNull("clearing authorization failed", c2);
     }
 
 
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java
index 5a604e2..3ba4f31 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java
@@ -46,12 +46,11 @@
         assertEquals("13", node.at("/meta/count").asText());
     }
 
+
     @Test
-    public void testbuildAndPostQuery() {
-        ClientResponse response = resource()
-                .path(getAPIVersion())
-                .path("search")
-                .queryParam("q", "[orth=das]")
+    public void testbuildAndPostQuery () {
+        ClientResponse response = resource().path(getAPIVersion())
+                .path("search").queryParam("q", "[orth=das]")
                 .queryParam("ql", "poliqarp")
                 .queryParam("cq", "corpusSigle=WPD | corpusSigle=GOE")
                 .method("TRACE", ClientResponse.class);
@@ -62,9 +61,8 @@
         JsonNode node = JsonUtils.readTree(query);
         assertNotNull(node);
 
-        response = resource()
-                .path(getAPIVersion())
-                .path("search").post(ClientResponse.class, query);
+        response = resource().path(getAPIVersion()).path("search")
+                .post(ClientResponse.class, query);
 
         assertEquals(ClientResponse.Status.OK.getStatusCode(),
                 response.getStatus());
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
index 6a5ab99..039593e 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
@@ -42,6 +42,7 @@
 
         JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
         assertNotNull(node);
+        System.out.println("NODE " + node);
         assertNotEquals(0, node.path("matches").size());
     }