Enhanced testing to checkTestingCastable

checkTestingCastable now tests that:
* After casting to type X, the output of the module is within a
certain tollerance of the original output
* After casting to type X, the input gradient of the module is within a
certain tollerance of the original input gradient
* After casting to type X, all components of a module have been
correctly cast
Updated documentation
Take care of possible circular references