fix unused code
fix pep8, fix tests, bugfix