On gauge invariance and spontaneous symmetry breaking