Various optimizations to IO::Path.contents.

Eliminate duplicate application of $test on MoarVM; probably just an
accident in porting. Then do a range of other optimizations. Cuts the
time taken to less than half of what it was.