Test for exact differential equations. I did not understand the proof for the reverse direction of the statement

$M(x,y)dx + N(x,y)dy = 0$ is exact if and only if $\dfrac{\partial M}{\partial y} = \dfrac{\partial N}{\partial x}$.

in the book Differential Equations with Applications and Historical Notes by George F. Simmons. The forward direction is pretty straight forward. For the reverse direction he starts with $f = \int Mdx + g(y)$. He then partially differentiates w.r.t $y$ and then substitutes $\dfrac{\partial f}{\partial y}$ as $N$. How can he assume existence of a function $f$ such that $ 
\dfrac{\partial f}{\partial x} = M $ and $ \dfrac{\partial f}{\partial y} = N$? I thought that's what's we're trying to prove that if $\dfrac{\partial M}{\partial y} = \dfrac{\partial N}{\partial x} \implies$ the equation is exact, that is there exists a function $f$ such that $\dfrac{\partial f}{\partial x} = M$ and $\dfrac{\partial f}{\partial y} = N$.
If you do not understand my question then just tell me how to prove the reverse direction of the first statement.
 A: We need to remember all hypothesis about this theorem.

Theorem. Let the function $M,N,M_{x},N_{y}$ be continuous in the rectangle region $\mathscr{R}: \alpha<x<\beta, \gamma<y<\delta$. The equation $$M(x,y)+N(x,y)\frac{dy}{dx}=0$$ is an exact differential equation in $\mathscr{R}$ if and only if $$\frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}$$at each point of $\mathscr{R}$.

Note that the theorem say:

There exists a function $\psi$ satisfyng equation $$\frac{\partial \psi}{\partial x}=M(x,y), \quad \text{and} \quad \frac{\partial \psi}{\partial y}=N(x,y)$$ if and only if $M$ and $N$ satisfy equation $$\frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}$$

Proof: The proof of this theorem has two parts.
$(\implies)$ We need to show that if there is a function $\psi$ such that equation $$\frac{\partial \psi}{\partial x}=M(x,y), \quad \text{and} \quad \frac{\partial \psi}{\partial y}=N(x,y)$$ are true, then it follows that equation $$\frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}$$ is satisfied. Computing $M_{y}$ and $N_{x}$ from equation $$\frac{\partial \psi}{\partial x}=M(x,y), \quad \text{and} \quad \frac{\partial \psi}{\partial y}=N(x,y)$$we obtain $$M_{y}(x,y)=\psi_{xy}(x,y) \quad \text{and} \quad N_{x}(x,y)=\psi_{yx}(x,y)$$Now, since $M_{y}$ and $N_{x}$ are continuous, it follows that $\psi_{xy}$ and $\psi_{yx}$ are also continuous. This guarantees theis equality, and equation $$\frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}$$ is valid.
$(\Longleftarrow)$ Here we need to show that if $M$ and $N$ satisfy equation $$\frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}$$then equation $$M(x,y)+N(x,y)\frac{dy}{dx}=0$$ is exact differential equation. For this, the proof involves the construction of a function $\psi$ satisfyng equations $$\frac{\partial \psi}{\partial x}=M(x,y), \quad \text{and} \quad \frac{\partial \psi}{\partial y}=N(x,y)$$So, we can begin by integrating the first of equation above with respect to $x$, holding $y$ constant (note that you can make a similar process integrating respect to $y$ and holding $x$ constant). We obtain $$\psi(x,y)=Q(x,y)+h(y)$$where $Q(x,y)$ is any differential function s.t $Q_{x}=M(x,y)$. For example, we can might choose $$Q(x,y)=\int_{[x_{0},x]}M(s,t)ds$$where $x_{0}$ is some specified constant with $\alpha<x_{0}<\beta$. The function $h$ is an arbitrary differentiable function of $y$, playing the role of the arbitrary constant with respect to $x$. Now, we must show it's always possible to choose $h(y)$ so that the second of equations $$\frac{\partial \psi}{\partial x}=M(x,y), \quad \text{and} \quad \frac{\partial \psi}{\partial y}=N(x,y)$$ is satisfied, that's $\psi_{y}=N$. Now, by differentiating equation $$\psi(x,y)=Q(x,y)+h(y)$$with respect to $y$ we obtain $$\psi_{y}(x,y)=\frac{\partial Q}{\partial y}(x,y)+h'(y)\overbrace{=}^{\text{result equal to $N(x,y)$}} N(x,y)$$Then, solving for $h'(y)$, we have $$h'(y)=N(x,y)-\frac{\partial Q}{\partial y}(x,y)$$In order for us to determine $h(y)$ from equation above,the RHS of equation $h'(y)=N(x,y)-Q_{y}$, despite its appearence, must be a function of $y$ only. Now, here one way to show that this is true is to prove that its derivative with respect to $x$ is zero. Thus we differentiate the RHS of $h'(y)=N(x,y)-Q_{y}$ with respect to $x$, obtaining the expression $$\frac{\partial N}{\partial x}(x,y)-\frac{\partial}{\partial x}\frac{\partial Q}{\partial y}(x,y)=0$$ and interchanging the order of differentiation and since $Q_{x}=M$, we have $$\frac{\partial M}{\partial y}(x,y)=\frac{\partial N}{\partial x}(x,y)$$then we obtain the required function $\psi(x,y)$.
Note: It's not essential that the region be rectangular, only that it be simply connected.
A: The author defines $f$ to be $$f(x,y):=\int M(x,y)\,dx+g(y)$$ where $M$ is the given function $M$, and $g$ an integration "constant". He is free to do that.
From this definition follows that
$$\frac{\partial f}{\partial x}=M(x,y).$$
Now, differentiating under the integral sign,
$$\frac{\partial f}{\partial y}=\frac{\partial }{\partial y}\left(\int M(x,y)\,dx+g(y)\right)=\int \frac{\partial }{\partial y}M(x,y)\,dx+g'(y)$$ which equals, by hypothesis,
$$\int \frac{\partial }{\partial x}N(x,y)\,dx+g'(y)=N(x,y)+h(y).$$
