Add error messages and error path unit tests