Investigation of the Mg XII 8.42 Å doublet in solar flare spectra