Add tests, http codes, fix bugs