Unit tests and other small cleanups.