refactored tests and design