Implement new RESTful api with tests.
Refine tests.