How to refactor code that has no tests?