Use function's basedir instead of script invocation's

Card: analytics 1168
Change-Id: I8a9f29abde079a12fd8e06ff69ba81b37c62ee04