Added tests in factor, improved some docstrings, and PEP8