Generalized and made election tests more DRY