Adds unit tests and makes stylistic changes.

These tests take too long at the moment and as such
are not ready for push to master.
This will likely fail the automated tests by Jenkins.
This is here for completeness and for review.