fixed bug regarding detection of end of stream + added unit tests
Merge branch 'WorkingAroundConnectionsReleasing' into integration