refactor, dry and more tests