optimize datepicker test code