A second implementation that does half the work; more tests