Fixing tests, better error handling

same comment as above