Do tests let you understand a codebase you have not written?
The spec and the test are your human contribution.
To have useful tests, you must write the APIs for the functions, and give examples of how to wire up the various constructs, and correct input/output pairs.
Implementations of those functions that pass the test now have significant constraints that mean you understand a lot about it.
First you write the tests, then you write code until tests pass.