Add license
Set correct HTTP status code on errors
Add tests

In preparation of some refactorings, add tests. Fix failed tests ;)