Electrochemical Insertion of Magnesium in Metal Oxides and Sulfides from Aprotic Electrolytes