Fix bug to cover rank in test cases