Ab initio study of tungsten defects near the surface