src/java: Change importToBibtex to reflect implementation

Also take care of cases where a nullptr is given to the function
src/test: Add test coverage for failure case in importToBibtex