Remove unused functions and add more test coverage