Avoid redundant call to getElements function
Add key for JNI result
Add working sort test