reworking file structure and adding tests

pep8 conformance plus added doctests and completely changed around the
file structure.