Fix upload bugs and add upload test case.

See jjjake/ia-wrapper#25