Wrap client code in closure too.

Update parties and test helpers to not use file-level vars.