fix #8134

Fix issue #8134
Added unit test for this fix.