Improved the test for refs #22682.

Thanks apollo13 for the review.