Add tests for reading invalid files

Also fixed a few error messages that weren't clear.