Fixed issue with wrapper passing wrong handle to callback.
Added tests.
Merge remote-tracking branch 'origin/master'