Clean up and add missing tests.