The immunity grant needed to compel testimony is also fairly limited. All they have to grant is immunity from the specific compelled statements (and evidence derived from them) being used against the witness in court; that was decided in a 1972 case [1]. The U.S. Supreme Court's reasoning was that, since the 5th amendment only protects withholding statements that might be incriminating, a grant of immunity relating only to those specific statements is sufficient to make compelling them constitutional, because they then can no longer function to legally incriminate. The government can still prosecute the compelled witness in the same case, if they have other evidence.
[1] An old law-review article on the case: http://digitalcommons.lmu.edu/cgi/viewcontent.cgi?article=11...