rewrite tests to refactor code