Holes localized in nanostructures in an external magnetic field: g-factor and mixing of states