Adding Unit Tests , Refactoring Code