Fixed spurious failures in the java tests