adding tdd for string and refactoring code