More tests and error handling