Fixed tests.
Refactoring.