refactoring of spec testing