Surface studies of Li-ion and Mg battery electrodes