extended error handling and tests