refactored domain/persistence and tests