make unit tests work, add saner error handling