Adding docstrings and tests