Added docstrings and comments.
Rearranged the order of tests.