Fix race condition in secure_cartridge

Remove Dir.chdir and use absolute file paths instead because chdir is
not thread-safe.

Bug 998345
Bug 1025043