refactor unit tests and remove unused code