On nearly Sasakian and nearly cosymplectic manifolds