Fix handling of optional hashref args to emit methods.

Also fixed issue where Tuple class did not have TO_JSON method.

Unit tests just need to be tweaked so that JSON is sorted by key,
because currently tests will randomly fail due to ordering issues.