Use $stdout instead of STDOUT

Currently `parse` uses `STDOUT` to check if the output is going a terminal.
However, the actual output `$stdout` may have been reassigned. This is just a
simple change to use `$stdout` instead with a hack to make tests continue to
work.