Fixed #19895 -- Second iterator over invalid qs raises errors

The fix was already in the patch for #18702, so only test added for
ticket #19895.