More tests and some cleanup.