added helper methods and java tests