test and doc for stream.end