Fix a couple of memory leaks in tests. Fix a potential case that length could be zero. Bug: 23762183 Test: Ran unit tests, then ran valgrind on unit tests and verified no leaks. Change-Id: I5f7602aa0204db0488a8e305250658cdb6e977d0
Bug: 23762183 Test: All new unit tests pass. Change-Id: I26a1f6e84bf1a02447eff48ff6e35068554330fe