fixed a unittest bug - payload files are now closed after being read

### Description
Fixed a unit-test bug.
The heavily used function that opens and reads the payload files for unit tests (testDataFromFile) now closes the file after reading it.