Fix memory leak issue when pipe to a slow stream

See #12 
Test added.
Sorry for creating a new pull request for this, I deleted the old fork.