Fix some errors in python code that prevent tests from functioning correctly.