fix and added tests