Ability to use custom handle

I had originally plumbed this code in, but missed a couple of key lines
to make sure it all worked.
First unit test

Added basic unit test, using qunit. This exposed a bug in my last check
in, which I also fixed :-)