debug of return_last_entry function (and test script)