Added sorting tests

• Added tests for sorting module
• Fixing bugs associated with sorting module
• Cleaning up interface a little bit