Fixing serialization of ajax requests.

Also including integration tests.