Added the 'replace_all_refs' and tests from the pyjack module