Fix two segaults in test code. Thanks to Sergey Popov for reporting this. Change-Id: Ib5124a90fc42ae9d7295c04d51a5dd8d16250504