Ensure script has completed before running test