Refactor spec so it fails consistently and properly retrieve filename.

This corrects the previous deficient spec, and provides a proper implementation.