Added a test for Output handling. Also fixed some related bugs.