Rewrite with pytest