Fix Accumulators in Java, and add a test for them