More unit tests and error checks.