Extact output() method to aid unit testing.