add support for dumping output to string, for testing purposes