Yes, refactoring is a good way to improve a code, but it will definitively change the behavior of this code.

Since this project is not secured by unit-tests, I will not take the responsibility of changing the behavior of it.

Using vars() or __dict__ and a string matching is the solution.