Refactoed unittests.