Fixed #22308 -- Regression from 0f956085.

Rewrote the test for #9479 according to the original ticket.