Test: Implement universal module setup/teardown

This implements the equivalent of setup/teardown methods that are define once for the entire testsuite, but run for each test. To make this easier to understand, we've went from setup/teardown to beforeEach/afterEach, renaming the existing module properties at the same time (in a separate commit).

Fixes #633 
this is named `lifecycle` in the api documentation.