Started writing unit tests

So, with Travis in place I think it's time to create a good test suite.

This is by no means a completed test suite, but it's a start. It could also be refactored to remove duplication.

Hopefully, this will make it easier for others to start writing tests.