Refactor domain classes and tests