Fix compatibility of some tests with java8