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.
Merge pull request #2349 from kristaps/patch-1

Make sure app references same object