fix issue in MinDistanceOfThreeTuples, and add unit test for it