Move new var into thunk.

There really was no reason for it to be in the
outer context.
Add unit test for datatype handling in updateAttributes.