Try not to crash.

While I can't reproduce the crash myself, hope it may help to fix it...

CCBUG: 336741
Fix the unit test.