improve coverage and error handling