toScriptValueIAttribute: fix potential crash by adding null check + return JS null properly in case of a null IAttribute pointer. Add tests for creating attribute with an invalid type name.