Well, my original speculation was that this.test was pointing to a memory address which didn't get cleaned up properly when you did clearemptyvars(), so accessing it would cause a seg fault.
But the fact that you can call getdynamicvars and add it to an array but not echo it seems a bit weird...
Maybe it has to do with casting the response of getdynamicvars to a string?