java/db: User entity handling fix

* User entity handling fix
* Small UT improvements.
Tiny fixes.
Merge remote-tracking branch 'origin/master'