Added more tests, got the test infrastructure reasonably up to date

- More test coverage.
- Added factory_boy and mock.