The structure and bonding in small MoS2 structures with and without Co is studied theoretically using self-consistent density functional theory with a non-local exchange-correlation energy. The structures model the catalysts used extensively in hydrotreating. We study in detail the structure and binding energies as a function of the amount of sulfur. The calculations show that extensive reconstructions occur at the two types of MoS2 edges where the sulfur dimerizes and occupies non-lattice positions. These structures are shown to be in good agreement with available experimental data. We also study the energy required to form sulfur vacancies, which are believed to be the active sites for many hydrotreating reactions. The presence of Co atoms at the edges is shown to lead to a significant lowering of the metal-sulfur binding energy. This imposes an increase in the concentration of active sites for the reactions and may thus explain the promoting effect of Co.