Fixes #1149: Test swallows output buffer when run in a separate process.

Tests run in isolation now:

  * Use the same output interface as normal tests.
  * Print the output after the test is ended like normal tests.
Merge branch '4.1' into 4.2
Merge branch '4.2'