Clean up code and remove duplicate tests.