Biaxial magnetic structures in rare-earth compounds: GdMg and HoP