Properties of two-dimensional insulators: A DFT study of Co adsorption on NaCl and MgO ultrathin films