refactoring of code for using test