Fixes #5235 bug causing incorrect renaming of numeric keys
(and adds test for reproducing and verifying fix)
Merge pull request #5238 from andyfleming/4.2-fix-5235

[4.2] fix #5235