Improve code coverage

It’s WIP, I aim for ~100% coverage.

Closes gh-371.