Trace function calls in tests and write to file

@psav, let me know where to integrate artifactor.