Better errors

Wrote some tests and created a better, more verbose error reporting.