Improved JavaReference implementation and added some tests for them.