Extract the environment set up and tear down for tests

Using trial there is no setUpClass neither tearDownClass, the setting up
of the environment needs to be in an external class to be able to call
it from inhereted classes.
Add support for deferreds to memoize_method decorator