Make sure app references same object

If app is set and current_app is not, this function will fail due to the reference to app in the trace_task call.