Refactor and add more tests
15 files changed