add test coverage (and a bit of error handling)