improved tests for files_encryption

- fixed testPermanentDeleteFile sometimes failed
- speed optimization
- reformat code

cc @schiesbn @DeepDiver1975