test and raise error for invalid years