Simplified certain Quantity related functions and added tests.