More tests, better error handling