Let’s say I come across a piece of code that I want to refactor but unfortunately
a) I don’t understand what it does and
b) it’s not covered by tests.
Yupp. That's a problem. How I write characterization tests shows a technique for how to deal with this situation. I, too, use tests to figure out how a piece of code actually works. Works better for me than actually reading the code. 🤨