A non-stoichiometric model of the composition of the atmospheres of Mercury and the Moon