Refactored and implemented some tests.