Update factory and related tests

* Delete unnecessary comments from factory.
* Change related factory to accept user parameter.
* Add better docstrings and comments to the related tests.
* Add test to check for invalid sort option.