Increasing test coverage and fixing bugs found while writing tests

This should be fine though since I am not redirecting `sys.stdout` here.