correct save/remove behiour of enum indexes ,fixes #2703
more appropriate conditional branching
fix test assertion
checkstyle fix
Merge pull request #2720 from eminn/fix/RemoveEnumIndex

correct save/remove behiour of enum indexes ,fixes #2703