Add some tests and fix code to make them pass.

Pity that jQuery only accepts functions in $.Callbacks. It should really accept
anything that looks like a function.