More tests.

Wrote more tests, made code more testable.