add sinon, add tests, refactorings