Add real tests

More tests are still needed, but this is a very strong start. This puts
us at 77.5% line coverage and 59.5% branch coverage.
7 files changed