added test for closing stream
added test for closing stream