diff --git a/core/pom.xml b/core/pom.xml
index d26d09a6d437c93d9d99194a89fc856c9818c4f8..86f1f88cc12c45fb02bfad3c5dd36e3b4b5a2851 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -26,6 +26,12 @@
       <artifactId>jackson-core-asl</artifactId>
       <version>${jackson.api.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.testng</groupId>
+      <artifactId>testng</artifactId>
+      <version>6.1.1</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>	
 
 </project>
diff --git a/core/src/main/java/com/yahoo/ycsb/RandomByteIterator.java b/core/src/main/java/com/yahoo/ycsb/RandomByteIterator.java
index 99239f859fb8011e663af50acaa985b09a6d0586..65db4335035ef22be38f249cc9b6ab7dcb92fe7e 100644
--- a/core/src/main/java/com/yahoo/ycsb/RandomByteIterator.java
+++ b/core/src/main/java/com/yahoo/ycsb/RandomByteIterator.java
@@ -1,84 +1,87 @@
-/**                                                                                                                                                                                
- * Copyright (c) 2010 Yahoo! Inc. All rights reserved.                                                                                                                             
- *                                                                                                                                                                                 
- * Licensed 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. See accompanying                                                                                                                 
- * LICENSE file.                                                                                                                                                                   
+/**
+ * Copyright (c) 2010 Yahoo! Inc. All rights reserved.
+ *
+ * Licensed 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. See accompanying
+ * LICENSE file.
  */
 package com.yahoo.ycsb;
 
+/**
+ *  A ByteIterator that generates a random sequence of bytes.
+ */
 public class RandomByteIterator extends ByteIterator {
-	long len;
-	long off;
-	int buf_off;
-	byte[] buf;
-	
-	@Override
-	public boolean hasNext() {
-		return (off + buf_off) < len;
-	}
+  private long len;
+  private long off;
+  private int bufOff;
+  private byte[] buf;
+
+  @Override
+  public boolean hasNext() {
+    return (off + bufOff) < len;
+  }
+
+  private void fillBytesImpl(byte[] buffer, int base) {
+    int bytes = Utils.random().nextInt();
+    try {
+      buffer[base+0] = (byte)(((bytes) & 31) + ' ');
+      buffer[base+1] = (byte)(((bytes >> 5) & 31) + ' ');
+      buffer[base+2] = (byte)(((bytes >> 10) & 31) + ' ');
+      buffer[base+3] = (byte)(((bytes >> 15) & 31) + ' ');
+      buffer[base+4] = (byte)(((bytes >> 20) & 31) + ' ');
+      buffer[base+5] = (byte)(((bytes >> 25) & 31) + ' ');
+    } catch (ArrayIndexOutOfBoundsException e) { /* ignore it */ }
+  }
+
+  private void fillBytes() {
+    if(bufOff ==  buf.length) {
+      fillBytesImpl(buf, 0);
+      bufOff = 0;
+      off += buf.length;
+    }
+  }
+
+  public RandomByteIterator(long len) {
+    this.len = len;
+    this.buf = new byte[6];
+    this.bufOff = buf.length;
+    fillBytes();
+    this.off = 0;
+  }
+
+  public byte nextByte() {
+    fillBytes();
+    bufOff++;
+    return buf[bufOff-1];
+  }
 
-	private void fillBytesImpl(byte[] buf, int base) {
-		int bytes = Utils.random().nextInt();
-		try {
-			buf[base+0] = (byte)(((bytes      ) & 31) + ' ');
-			buf[base+1] = (byte)(((bytes >> 5 ) & 31) + ' ');
-			buf[base+2] = (byte)(((bytes >> 10) & 31) + ' ');
-			buf[base+3] = (byte)(((bytes >> 15) & 31) + ' ');
-			buf[base+4] = (byte)(((bytes >> 20) & 31) + ' ');
-			buf[base+5] = (byte)(((bytes >> 25) & 31) + ' ');
-		} catch (ArrayIndexOutOfBoundsException e) { /* ignore it */ }
-	}
-	
-	private void fillBytes() {
-		if(buf_off ==  buf.length) {
-			fillBytesImpl(buf, 0);
-			buf_off = 0;
-			off += buf.length;
-		}
-	}
-	
-	public RandomByteIterator(long len) {
-		this.len = len;
-		this.buf = new byte[6];
-		this.buf_off = buf.length;
-		fillBytes();
-		this.off = 0;
-	}
+  @Override
+  public int nextBuf(byte[] buffer, int bufferOffset) {
+    int ret;
+    if(len - off < buffer.length - bufferOffset) {
+      ret = (int)(len - off);
+    } else {
+      ret = buffer.length - bufferOffset;
+    }
+    int i;
+    for(i = 0; i < ret; i+=6) {
+      fillBytesImpl(buffer, i + bufferOffset);
+    }
+    off+=ret;
+    return ret + bufferOffset;
+  }
 
-	public byte nextByte() {
-		fillBytes();
-		buf_off++;
-		return buf[buf_off-1];
-	}
-	@Override
-	public int nextBuf(byte[] b, int buf_off) {
-		int ret;
-		if(len - off < b.length - buf_off) {
-			ret = (int)(len - off);
-		} else {
-			ret = b.length - buf_off;
-		}
-		int i;
-		for(i = 0; i < ret; i+=6) {
-			fillBytesImpl(b, i+buf_off);
-		}
-		off+=ret;
-		return ret + buf_off;
-	}
-	
-	
-	@Override
-	public long bytesLeft() {
-		return len - off;
-	}
+  @Override
+  public long bytesLeft() {
+    return len - off - bufOff;
+  }
 }
diff --git a/core/src/test/java/com/yahoo/ycsb/TestByteIterator.java b/core/src/test/java/com/yahoo/ycsb/TestByteIterator.java
new file mode 100644
index 0000000000000000000000000000000000000000..b95415b09a89e15540983694a7c53ea1870116ce
--- /dev/null
+++ b/core/src/test/java/com/yahoo/ycsb/TestByteIterator.java
@@ -0,0 +1,22 @@
+package com.yahoo.ycsb;
+
+import org.testng.annotations.Test;
+import static org.testng.AssertJUnit.*;
+
+public class TestByteIterator {
+  @Test
+  public void testRandomByteIterator() {
+    int size = 100;
+    ByteIterator itor = new RandomByteIterator(size);
+    assertTrue(itor.hasNext());
+    assertEquals(size, itor.bytesLeft());
+    assertEquals(size, itor.toString().getBytes().length);
+    assertFalse(itor.hasNext());
+    assertEquals(0, itor.bytesLeft());
+
+    itor = new RandomByteIterator(size);
+    assertEquals(size, itor.toArray().length);
+    assertFalse(itor.hasNext());
+    assertEquals(0, itor.bytesLeft());
+  }
+}