splitted code into library and test suite