Fix crash on device state changed callback and update recorder_test code