refactor factory test