Could you have committed an unrelated murder, and by disclosing this murder in your testimony, become immune to conviction of it?
If that is not how immunity works, then how can the government force anyone to testify? The government does not know what (unrelated) crimes I may have to confess to in order to give truthful testimony on the matter in question.