Simplify code for after(), patch() and modify_return_value().

Extract the common code into get_decorator_or_context_object(), and
allow using the non-decorator versions as contexts for temporary
patching.