Ab initio molecular dynamics of ion solvation. The case of Be2+ in water