refactors sales engine and tests