Fix boundary logic in divergence removal and add a 2d test.