Code refactoring, add setup.py and tests
Add file for Travis CI