Add optional argument in constructor to redirect output.
Wrote a test.