adding testem script and a bit of refreactoring to make it work