Use _.contains instead of Array.indexOf
Added test for nested empty elements