conformed to PEP8, fixed a small bug, and added tests