Rewrite tests using  function