fix crash bug and add more test case

1. fix crash of double free data buffer
2. add more test case of authentication
3. change display of the debug message flow