CompareTo and Tests

Updated compareTo logic to be more robust, and added several test cases