Measurements of the polarization of the 2p and 1s states in muonic atoms and the helicity of the muon in pion decay