Initial refactoring: added package structure and build file, extracted unit tests