Test that middleware throws error