adding test and refactoring stuff