Add test file

Slightly sucks in terms of copying the function from one file to another
to test, but highlighted a bug and let me improve the error reporting
code.
Reorder error reporting

When we have multiple things in the same file, we’d like to get errors
in sequential order, rather than reversed.