Connection factory was ignored when cursor was created. Baed on jzlatov's pull request.
Added extra checks for a closed pool.