refactor and simplify classes and test in core module.
fix percent discount logic.