In symplectic geometry, given a manifold $M$ with closed nondegenerate symplectic 2-form $\omega$, it is known that a vector field $X$ is Hamiltonian if $$\iota_X\omega=dH$$ for some smooth function $H\in C^\infty(M)$. A vector field is symplectic if it preserves the symplectic structure along the flow, i.e. $$\mathcal L_X\omega=0\,.$$
One of the easiest ways to check them is to note that if $X$ is symplectic then $\iota_X\omega$ is closed, and if $X$ is Hamiltonian then $\iota_X\omega$ is exact. Consequently, all Hamiltonian vector fields are symplectic but the converse is not true. Locally, however, Poincare lemma guarantees that every symplectic vector field is Hamiltonian.
Now consider symplectic 2-torus $(\mathbb T^2,d\theta\wedge d\phi)$ and a vector field $$X=\frac{\partial}{\partial \theta}\,.$$
Using the first de Rham cohomology, one usually concludes that $X$ is not Hamiltonian. However, I am unsure why: note that $\iota_X\omega=d\phi$, so it looks to me this is exact. Of course, we see that $\phi$ is not globally defined on $\mathbb T^2$, so perhaps this is not correct. But this argument would seem to imply that for symplectic 2-sphere $(S^2,d\theta\wedge d\phi)$, $X$ is not Hamiltonian (even though it should be, since it is symplectic and $$H^1_{\text{de Rham}}(S^2)=0\,.$$
Another example: Consider symplectic 2-sphere $(S^2,d\theta\wedge dh$), where $H(\theta,h)=h$ is a height function. In this case, the same vector field $X$ is Hamiltonian, since we obtained the required smooth Hamiltonian function $H$. Now I reverse the problem: consider another 2-torus $(\mathbb T^2,d\theta\wedge dh)$ and the same vector field $X$. Now it looks like $X$ is Hamiltonian, even though we know $$H^1_{\text{de Rham}}(\mathbb T^2)\neq0\,.$$
From my (naive) understanding, $H^1_{\text{de Rham}}(M)$ should be the only obstruction for a symplectic vector field to be Hamiltonian vector field, and not on the choice of the symplectic 2-form.
Question: What has gone wrong here? For the first example, for instance, it may have to do with seeing that $d\phi$ is not exterior derivative of $\phi$, which I may have misunderstood.