New test helper function to check that we got the error we wanted

This simplifies a bunch of our tests and, again, reduces duplication
Indeed it's arguable whether or not it's any easier to read in its current form, but a new version I've pushed should make that much clearer, while fixing the bug you pointed out. The reason why I decided to change this, though, is to avoid code duplication, either maintaining the same clarity or improving it -- it's not about the number of lines we save.

I don't like functions with lots of arguments either, but most test helper functions in Go will take a testing.T as first argument, and in this one the second and third arguments are the errors it's comparing (which should now be clearer given the new function name). It may not be completely obvious the first time you see it (although now I'd say it is given that all callsites are passing variables instead of literals as arguments), but every subsequent time it surely will be, and that's not the case when you have a 10-line if/else block.