fix some bugs, add tests, send POST data correctly, rename a couple of functions