fixed error handling, added second set of tests