Mg/Pd and Ba/Pd interfaces with and without hydrogen