For ENG-6530, refacor the logic, add one more test case.