add first encoder test and fix mem leak it found