update arithmetic script test, refactor code, add java doc