Refactory a little bit, add tests
Add travis ci configuration