Fixing issue with malformed attributes, regression tests also included.