Refactor tests.

I began with some coarse integration tests.  This rounds things out with more unit tests.