Add support for CJob cancellation and necessary module support

This makes it possible for modules to use CJob instances.

To do so, it must be possible to enforce that all of a module's jobs are done when the module is unloaded. This in turn means that we need to be able to cancel CJob instances.

This PR begins with some cleanups and a simple test for CJob in the testsuite, then comes the cancellation support for CJob and the necessary wrappers for modules.