Added ability to capture output for test purposes