Add a few end-to-end tests to ensure everything works

Some of this code is pretty ugly and will need to be refactored,
but the tests all work :grinning: