Increasing test coverage and fixing bugs found while writing tests

Again, no `sys.stdout` redirection here, so this should be fine.