completed stream tests and fixed bugs in writing