removed unused code and added tests