fixed stream, added test