Fix test and pep8 issues