Remove some unused code and add more tests