Fixing tests, better error handling