Improve error message, add unit tests for missing nil cases.