Added doctests, fixed a small bug, pep8