Add fix for Java 7
Add tests