Collective refraction of a beam of electrons at a plasma-gas interface