Extract calculation of convergence rate in tests.py

* Separate function so that we can use it in parse.py