Section 20H. If a witness has been granted immunity pursuant to the provisions of section twenty E by a justice of the supreme judicial court, appeals court or superior court and thereafter refuses to testify or produce evidence after being so ordered by such justice, the attorney general or district attorney shall institute contempt proceedings against such witness in the court where the alleged contempt occurred, and, after hearing or trial, if such witness is adjudged in contempt of court, he shall be punished by imprisonment in the house of correction for a term not to exceed one year or until he complies with the order of the court, whichever occurs first. The rules of practice and procedure relative to criminal appeals as provided by the Massachusetts Rules of Criminal Procedure and the Massachusetts Rules of Appellate Procedure shall apply to appeals under this section.