Add error management + add some unit tests

We need to merge the #12 first