Makes profiling run in the python tests.

Also several fixes to make the tests pass.