Fix test breakages and pep8