Added comments and unit tests for most functions in SortLogs