fixed and added tests