Ensure transaction/env are still valid before deallocating cursor.
Extension improvements

* Use simpler scheme to emulate forward()/reverse() behavior.
* Make Environment.close() ignore repeated calls like cffi does.
Implement set_key() and set_range().