Fix test instability on JDK 8