Tests: Simplify stdout redirection and fix Windows assertion error on cleanup

* cleanup_test_output() produced an assertion error when compiled with MSVC
  due to closing ctx->output_file
* set ctx->output_file to stdout by default