Additional tests and better error handling