added comments and fixed failed tests