tests and subsequent refactoring