Added unit tests and fixed log file sorting.