Rewrite test using  function