Add unit tests and java doc