Re-ordered bundle() callback fixing to before pending check

cb358b265441b088a232e3bf581601af5e74582e added a fix for potential double callbacks, but it didn't quite catch the case where a bundle was pending because that makes a recursive call with the un-fixed `cb`, and so some cases were still calling back more than once.

Moving the callback fix to before the point at which the code branched for pending bundles fixes this.