fix unit tests and pep8 errors