Use $ENV{TMPDIR} if defined

This package can't be built on Android. On this system there is no /tmp directory. It is better to utilise $TMPDIR environment variable so the test pass on any system with proper directory in $TMPDIR.