Bugfixes and tests for serializer.

Also fixed some bugs in the REST adapter.
Finished updating JSON serializer.
Updated REST adapter and tests.