Fix the issue with 2 consecutive tests and deallocation.