Fix previous fix

Previous fix used a Py_INCREF result as if it was the parameter, and
only worked in testing by chance. Fixed to work properly, and moved to
a convenience function to avoid future errors.