Rewrite existing tests and fill in implementation