Remove unused code and add a test.