Pennsylvania's top elections official spent hours in federal court Tuesday, defending the certification of voting machines being used by Philadelphia and two other Pennsylvania counties, including one where problems led to undercounted returns in a race in November.