tests and error handling