The effect of reverse currents on the dynamics of nonthermal electron beams in solar flares and on their emitted X-ray bremsstrahlung