refactoring of put test function