Refactoring java and python
Fix test error
Make build function registerable
Add missing imports