Formation, structure and magnetism of the γ-(Fe,M)23C6 (M = Cr, Ni) phases: A first-principles study