- removed code that doesn't work anymore
- added testcase
- fixed stream use and cleanup