Improve coverage and handle error case