Fixed and added tests