Test wrapping on rectangular grid.  Fix code