Improve testability a little.
Fix some testability; add more tests.