Cart: Fix for discount calculation bug

Quanity was not always taken into consideration when calculating actual
amounts. This commit fixes that.

Also adds test for verifying the correctness of the logic.

ping @MrShish