I wonder why this is relevant at all - sure, I understand that with this algorithm you can have option strings hardcoded in tests and the test still succeed even if the respective strings change in the system.

But why hardcode strings in tests in the first place?

Furthermore, you've now spent a hell of a thread on an algorithm that has thousands of examples and discussions all over the internet - i.e. it seems neither a new problem nor a new solution here, so all you need to do is to check whether you copied it correctly, and then move on to the real problem - i.e. do the tests now actually work reliably across templates?

My first thought was though that this is "just" a test helper function, and the idea was to *simplify* those, not to complicate them even further - it must be obvious what it does, it must be easy to find and resolve bugs in these test helper functions - otherwise they are definitely not suitable a means to help us to detect and diagnose bugs in our production code.

Right now, the problem is that the test framework is too complicated, nested with too many levels of helpers and helper-helpers, no consistent pattern and difficult-to-understand code.

Are you sure this here is a good idea?
Dominic