Fix check of returned pointer status
Add passing test of returning a free pointer from lending function.