refactoring API to compatibility with jdk 1.8. tests