Fix tests and pep8