Fixed NoSuchElementException when a test prints something after the test run is finished

Fixes #1