Add more tests and remove unused code
Improve test coverage