discount bug fixes and tests