Fix #67, moved calling beforeEach and afterEach into Test.
Also added more unit tests.