Add local value to Scalar and implement apply with both insert and add modes.
Update Scalar implementation and tests after discussion in issue 338.
Merge branch 'martinal/fix-scalar-apply'