Use mktemp to test rules in a temporary directory.

mktemp creates a temporary directory under /tmp by default. This reduces the
chance for collisions with other scripts using the same directory.
Merge pull request #1 from yaunj/master

Use mktemp to create temporary directory