Each voting machine shall remain locked against voting for five (5) days after the certification of the election and as much longer as may be necessary or advisable because of a contest over the result of the election. When another election necessitating the use of a particular voting machine is to be held within a period of thirty (30) days after an election, that voting machine may be opened after five (5) days upon the agreement of all the candidates in the earlier election whose names appeared on the ballot on that machine. A voting machine may be opened and examined upon the order of any court of competent jurisdiction at any time.