Clean up pep8 and pylint violations

Also fixes failing Python unit tests