some refactoring w/ more tests