Handle custom attributes with empty values, fixes #270

Fixes Bug #270 

Also added a test that triggers the described error without that fix.