Add basic tests
Several error reporting fixes