Fix bug in generation of testhandle