stream handling in SelfTest

The two commits change the stream handling in the following way: if stream is None and a test fails, write the correct stream to sys.stderr and if stream is not None, pass it to TestTextRunner.