Is it possible that you use a mock instead of this...

I have a preliminary one in https://github.com/julienw/gaia/blob/867885-add-activity-handler-test-2/apps/sms/test/unit/mock_contacts.js, that use your `mock_contact.js` but it's maybe not good enough for you. I plan to use sinon.js so that we can control in the tests what the function will return, but I don't know if that will be easy.

With this code, you're not only testing thread_ui.js, but also contacts.js, and even your mock which has non-trivial code. This is really wrong for unit tests whereas all you really need here is some contacts to display.