In each case of a contested election, the court or legislative body may require the contestant to post bond for the costs and expenses of the election contest. The costs and expenses of any election contest, including the cost and expense of a recount, may be adjudged against the unsuccessful party with payment of the costs and expenses enforceable as in civil cases.