Improve quantity decorator and add tests.