refactoring and java test