Fix issue with optional clauses and empty lists.

After using this library a little I noticed an issue where empty lists
in an optional clause were still appending artifacts despite there
being nothing in the list.  I added handling for empty lists to make
it work more explicitly and I added a test case for optional clause
with an empty list to make the behavior stick around.