Fix unit test depending on Java version