Add unit and integration tests, along with validation and coverage

This brings coverage up to 72% which isn't great, but is better than before, and helps #9 along.