[TESTS]: create directory for heapdumps if not exists

Before the heapdump was either written in a file with the
directory name if the heapdump path ended without / or
not written at all if the path ended with /

closes #7645