fix lends tag inside nested function calls (#565)

plus some minor test cleanup