refactoring the library to be more pythonic, separated roles, updated tests