fix error handling
improve coverage