Fix and unit test for trac #17155