Re #9017. Added a test case to test the fix.