api tests: Fix to remove the 'filename' entry if None
Related 38e7478e51d9d6a65ea827a976bb1a4ea8149cec Related T621