Update test code and file handling

See title