This is a little hacky. When run via the unit test, it "fails" with an E and
then the error that is printed is exactly what is wanted. Though looking at
the code that is unexpected. Additionally, I try to write to the logfile,
but it's empty. I'm assuming it's because I don't close the file. But don't
know where the file should be closed. Don't want to close it too early.