refactor and add more tests
more tests