Add support for testing thrown exceptions
Fix trimming to work as intended

It was previously trimming the input and the expected output, whereas it should be trimming the actual output and the expected output.