Put testPluginDir check in a closure

Signed-off-by: Ian Macalinao <me@ian.pw>