Fixes #5235 bug causing incorrect renaming of numeric keys (and adds test for reproducing and verifying fix)