Add a method to check for errors

See #10
Exit with code 1 when there are errors

Includes unit tests.

Fixes #10