Simplify shared_ptr extraction from Python object

Also avoid using the raw Python C API in favour of the boost python wrappers to
ensure that the reference counting is dealt with properly
Refs #9513
Fix PythonAlgorithmTraitsTest

The object returned from the factory now has been downcast to the
correct type in Python meaning in the tests the methods are bypassing
the base class in some cases.
Refs #9513
Merge branch 'bugfix/9513_pyobj_del_not_called' into develop