Fix trimming issue with lists

Change-Id: I9900a1c5062f314e02df59c55bbfa2a1b019f23f