fix tests and pep8 errors