Add Wait() calls in the appropriate spots

This adds Wait() (semantically appropriate versions) where appropriate.

**Note:** I cannot run the `buildfile_test.go` integrations test with passing results either with or without this patch. I spent a bit of time trying to diagnose that, but was unsuccessful at finding the cause. I will report a bug instead, but this patch should not be merged until someone can get the integrations to pass successfully.

Fixes #5971