error handling and tests