This kind of "__main__" function is fine for toy scripts, but I'd expect some unit tests written. If you don't want to use something heavy, you can stick to doctests. However, current state of the code base makes it rather hard - small, single purpose methods are more readable, easier to understand and test.