Rewrite windows and better tests