Add unit tests for SameXxxAs, Refactor dateRangeOptimization tests to reduce redundancy.