Correct the ordering of tests in the elaboration of pattern matchings