diff --git a/LibOneM2M/OneM2M_Functions.ttcn b/LibOneM2M/OneM2M_Functions.ttcn
index ef908a33da04a5639e538b5c062b97f8874d9736..185f545b4bbb63826b39c55da5ee7373f407b348 100644
--- a/LibOneM2M/OneM2M_Functions.ttcn
+++ b/LibOneM2M/OneM2M_Functions.ttcn
@@ -868,30 +868,34 @@ module OneM2M_Functions {
 				var integer v_resourceIndex;
 				
 				// AE TODO To review the code (use of indexes, generation of value for certain attributes, etc..)
-				if(p_resourceType == int2 and ischosen(p_resource.any_1[0].AE_optional)) {
-					var AE_optional v_ae := p_resource.any_1[0].AE_optional;
-					var AE_optional v_aeModified;					
-					
-					v_resourceIndex := lengthof(vc_resourcesList) - 1;
-					v_ae.resourceType := p_resourceType;
-					
-					v_ae.parentID := int2str(p_parentIndex);
-					v_ae.creationTime := fx_generateTimestamp();
-					v_ae.lastModifiedTime := v_ae.creationTime;											
-					v_ae.resourceID := "ae" & int2char(v_resourceIndex);
-					v_ae.aE_ID := "ae" & int2char(v_resourceIndex);
-					v_ae.resourceName := "ae" & int2char(v_resourceIndex);
-
-					v_aeModified.parentID := v_ae.parentID;
-					v_aeModified.creationTime := v_ae.creationTime;
-					v_aeModified.lastModifiedTime := v_ae.lastModifiedTime;											
-					v_aeModified.resourceID := v_ae.resourceID;
-					v_aeModified.aE_ID := v_ae.aE_ID;
-					v_aeModified.resourceName := v_ae.resourceName;
-					
-					p_resource.any_1[0].AE_optional := v_ae;
-					p_modifiedResource.AE_optional := v_aeModified;
-					return f_setResource(p_resource, p_parentIndex);					
+				if(p_resourceType == int2 and ispresent(p_resource)) {
+				  	if(ischosen(p_resource.any_1[0].AE_optional)){
+				      	var AE_optional v_ae := p_resource.any_1[0].AE_optional;
+      					var AE_optional v_aeModified;					
+      					
+      					v_resourceIndex := lengthof(vc_resourcesList) - 1;
+      					v_ae.resourceType := p_resourceType;
+      					
+      					v_ae.parentID := int2str(p_parentIndex);
+      					v_ae.creationTime := fx_generateTimestamp();
+      					v_ae.lastModifiedTime := v_ae.creationTime;											
+      					v_ae.resourceID := "ae" & int2char(v_resourceIndex);
+      					v_ae.aE_ID := "ae" & int2char(v_resourceIndex);
+      					v_ae.resourceName := "ae" & int2char(v_resourceIndex);
+      
+      					v_aeModified.parentID := v_ae.parentID;
+      					v_aeModified.creationTime := v_ae.creationTime;
+      					v_aeModified.lastModifiedTime := v_ae.lastModifiedTime;											
+      					v_aeModified.resourceID := v_ae.resourceID;
+      					v_aeModified.aE_ID := v_ae.aE_ID;
+      					v_aeModified.resourceName := v_ae.resourceName;
+      					
+      					p_resource.any_1[0].AE_optional := v_ae;
+      					p_modifiedResource.AE_optional := v_aeModified;
+      					return f_setResource(p_resource, p_parentIndex);			   
+				    
+				    }
+										
 				}	
 				
 				// TODO: implement other resource types			
diff --git a/LibOneM2M/OneM2M_Templates.ttcn b/LibOneM2M/OneM2M_Templates.ttcn
index 1a802fcc56a21c5b8c5841650aa605fb65c18e66..8867d91c54a008f61e89bc5d147f5e214d52bfd3 100644
--- a/LibOneM2M/OneM2M_Templates.ttcn
+++ b/LibOneM2M/OneM2M_Templates.ttcn
@@ -2381,7 +2381,7 @@ module OneM2M_Templates {
 		 * @param p_statusCode	Status code
 		 * @param p_requestId	Request ID of the corresponding request
 		 */
-		template (value) ResponsePrimitive m_responsePrimitive_content(in ResponseStatusCode p_statusCode, in RequestID p_requestId, in PrimitiveContent p_content) modifies m_responsePrimitive := {
+		template (value) ResponsePrimitive m_responsePrimitive_content(in ResponseStatusCode p_statusCode, in RequestID p_requestId, in template (value) PrimitiveContent p_content) modifies m_responsePrimitive := {
 			primitiveContent := p_content			
 		}
 		
diff --git a/OneM2M_Testcases.ttcn b/OneM2M_Testcases.ttcn
index 97e6214942815d23978c3aedbc47a890debde667..8d00db70da21f8fca1223f2df38e8c2c4567468f 100644
--- a/OneM2M_Testcases.ttcn
+++ b/OneM2M_Testcases.ttcn
@@ -1682,7 +1682,9 @@ module OneM2M_Testcases {
 							var MsgIn v_response;
 							var RequestPrimitive v_request;
 							var integer v_aeIndex := -1;
-											   
+							
+							var AttributeAux v_invalidAttribute;
+									   
 							// Test control
     				
 							// Test component configuration
@@ -1695,20 +1697,22 @@ module OneM2M_Testcases {
 						
 							// Test Body
 							v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
-    					
-							mcaPort.send(m_request(v_request, {valueof(p_invalidAttribute)}));
+							
+    						v_invalidAttribute := valueof(p_invalidAttribute);
+    						
+							mcaPort.send(m_request(v_request, {v_invalidAttribute}));
 							tc_ac.start;
 							alt {
 								[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
 									tc_ac.stop;
-									setverdict(pass, testcasename() & ": Creation rejected for resource type " & int2str(enum2int(p_resourceType)) & " containing an invalid value for attribute " & p_invalidAttribute.name);
+									setverdict(pass, testcasename() & ": Creation rejected for resource type " & int2str(enum2int(p_resourceType)) & " containing an invalid value for attribute " & v_invalidAttribute.name);
 								}
 								[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
 									tc_ac.stop;
-									setverdict(fail, testcasename() & ": Accepted creation of resource type " & int2str(enum2int(p_resourceType)) & " containing an invalid value for attribute" & p_invalidAttribute.name);
+									setverdict(fail, testcasename() & ": Accepted creation of resource type " & int2str(enum2int(p_resourceType)) & " containing an invalid value for attribute" & v_invalidAttribute.name);
 								}
 								[] tc_ac.timeout {
-									setverdict(inconc, testcasename() & ": No answer while creating resource type " & int2str(enum2int(p_resourceType)));
+									setverdict(inconc, testcasename() & ": No answer while creating resource type " & int2str(enum2int(p_resourceType)));  
 								}
 							}