Fix imports, PEP8 errors and tests.

Hello! I like your project, but codebase has been not so clean. I made some work and it will be pretty if you will accept my request. Thank you!