changed writestream to return a stream (instead of void)
added test for stream return value for writestream