Fixing tests, better error handling

Created issue #3 for this - no need to address it in this pull request