refactor class and tests
updated version