Refactor. Tests.