Refactor spec so it fails consistently and properly retrieve filename.