Fixed issues with the custom errors.
added model unit tests.

This includes fixes for issues discovered while writing them.
Updated the readme for documentation on the model api.