KAA-217: Fix memroy leaks in the profile test