diff --git oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java
index 0b67eea..7309772 100644
--- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java
+++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/MarkSweepGarbageCollector.java
@@ -473,14 +473,19 @@ public class MarkSweepGarbageCollector implements BlobGarbageCollector {
          * Instantiates a new file line difference iterator.
          */
         public FileLineDifferenceIterator(File marked, File available, int batchSize) throws IOException {
-            this.markedIter = FileUtils.lineIterator(marked);
-            this.allIter = FileUtils.lineIterator(available);
+            this(FileUtils.lineIterator(marked), FileUtils.lineIterator(available), batchSize);
+
+        }
+        public FileLineDifferenceIterator(LineIterator marked, LineIterator available, int batchSize) throws IOException {
+            this.markedIter = marked;
+            this.allIter = available;
             this.batchSize = batchSize;
             queue = new ArrayDeque<String>(batchSize);
             markedBuffer = Sets.newTreeSet();
 
         }
 
+
         /**
          * Close.
          */
diff --git oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/FileLineDifferenceIteratorTest.java oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/FileLineDifferenceIteratorTest.java
new file mode 100644
index 0000000..96807a7
--- /dev/null
+++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/blob/FileLineDifferenceIteratorTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.jackrabbit.oak.plugins.blob;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+import com.google.common.base.StandardSystemProperty;
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.io.LineIterator;
+import org.junit.Test;
+
+import static java.util.Arrays.asList;
+import static org.apache.jackrabbit.oak.plugins.blob.MarkSweepGarbageCollector.FileLineDifferenceIterator;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class FileLineDifferenceIteratorTest {
+    
+    @Test
+    public void testNoDiff() throws Exception{
+        assertDiff("a,b,c", "a,b,c", Collections.<String>emptyList());
+        assertDiff("a,b,c,d,f", "a,b,f", Collections.<String>emptyList());
+    }
+
+    @Test
+    public void testSimpleDiff() throws Exception{
+        assertDiff("a,b", "a,b,c", asList("c"));
+        assertDiff("a,b", "", Collections.<String>emptyList());
+        assertDiff("", "", Collections.<String>emptyList());
+        assertDiff("", "a", asList("a"));
+        assertDiff("", "a, b", asList("a", "b"));
+    }
+
+    @Test
+    public void testDiffWithExtraEntriesInMarked() throws IOException {
+        assertDiff("a,b", "a,b,c, e, h", asList("c", "e", "h"));
+        assertDiff("a,b,d,e", "a,b,c", asList("c"));
+        assertDiff("a,b,d,e,f", "a,b,c,f", asList("c"));
+        assertDiff("a,b,d,e,f", "a,b,c,f, h", asList("c","h"));
+    }
+
+    private void assertDiff(String marked, String all, List<String> diff) throws IOException {
+        Iterator<String> itr = createItr(marked, all);
+        assertThat(ImmutableList.copyOf(itr), is(diff));
+    }
+
+    private Iterator<String> createItr(String marked, String all) throws IOException {
+        return new FileLineDifferenceIterator(lineItr(marked), lineItr(all), 2);
+    }
+
+    private static LineIterator lineItr(String seq) {
+        Iterable<String> seqItr = Splitter.on(',').trimResults().split(seq);
+        String lines = Joiner.on(StandardSystemProperty.LINE_SEPARATOR.value()).join(seqItr);
+        return new LineIterator(new StringReader(lines));
+    }
+
+}
