Remove unused code and adjust unittests