[#1431] Improved tests and fixed pep8 errors