add beforeEach() and afterEach()

I added the beforeEach() and afterEach() methods which are executed before and after each single test. I tried to keep it clean and reused existing methods. Seems to work well for me so far.