more tests, better error handling