More unit tests. Improved error reporting.