Index: /ruby/branches/0.5/lib/open_ehr/rm/data_structures/item_structure.rb
===================================================================
--- /ruby/branches/0.5/lib/open_ehr/rm/data_structures/item_structure.rb	(revision 338)
+++ /ruby/branches/0.5/lib/open_ehr/rm/data_structures/item_structure.rb	(revision 339)
@@ -54,5 +54,5 @@
               return item if item.name.value == a_name
             end
-            retrun nil
+            return nil
           end
 
@@ -111,9 +111,5 @@
           def ith_row(i)
             raise ArgumentError, 'invalid index' if i<=0 or i>@rows.size
-            if @rows.nil?
-              return []
-            else
-              return @rows[i - 1]
-            end
+            return @rows[i - 1]
           end
 
@@ -139,5 +135,4 @@
               return row if row.items[0].name.value == key
             end
-            return []
           end
 
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/data_structure_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/data_structure_spec.rb	(revision 339)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/data_structure_spec.rb	(revision 339)
@@ -0,0 +1,21 @@
+require File.dirname(__FILE__) + '/../../../../spec_helper'
+include OpenEHR::RM::DataStructures
+include OpenEHR::RM::DataTypes::Text
+
+describe DataStructure do
+  before(:each) do
+    name = DvText.new(:value => 'test')
+    @data_structure = DataStructure.new(:archetype_node_id => 'at0001',
+                                        :name => name)
+  end
+
+  it 'should be an instance of DataStructure' do
+    @data_structure.should be_an_instance_of DataStructure
+  end
+
+  it 'should raise NotImplementedError' do
+    lambda {
+      @data_structure.as_hierarchy
+    }.should raise_error NotImplementedError
+  end
+end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb	(revision 338)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb	(revision 339)
@@ -36,6 +36,10 @@
   end
 
-  it 'retrieve the item with a name' do
+  it 'should return the item with a name' do
     @item_list.named_item('one').name.value.should == 'one'
+  end
+
+  it 'should return nil when item is not exist' do
+    @item_list.named_item('four').should be_nil
   end
 
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_single_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_single_spec.rb	(revision 338)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_single_spec.rb	(revision 339)
@@ -6,16 +6,24 @@
 
 describe ItemSingle do
-  before(:all) do
-    name = 
-    @element = Element.new(:name => DvText.new('item'),
-                           :archetype_node_id => 'AT0000',
-                           :value => DvQuantity.new())
-    item_single_name = DvText.new('item single')
+  before(:each) do
+    element = stub(Element, :archetype_node_id => 'at0002')
+    item_single_name = DvText.new(:value => 'item single')
     @item_single = ItemSingle.new(:name => item_single_name,
-                                  :archetype_node_id => 'test',
-                                  :item => @element)
-    
+                                  :archetype_node_id => 'at0001',
+                                  :item => element)
   end
 
+  it 'should be an instance of ItemSingle' do
+    @item_single.should be_an_instance_of ItemSingle
+  end
 
+  it 'should raise ArgumentError with nil item' do
+    lambda {
+      @item_single.item = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should return as_hierarchy' do
+    @item_single.as_hierarchy.archetype_node_id.should == 'at0002'
+  end
 end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb	(revision 338)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb	(revision 339)
@@ -45,4 +45,8 @@
   end
 
+  it 'column_count should be 0 when @rows == nil' do
+    @item_table.rows = nil
+    @item_table.column_count.should be_equal 0
+  end
 
   it 's row_names should be cluster cluster' do
@@ -96,4 +100,8 @@
   end
 
+  it 'should be false it has_column with name ten' do
+    @item_table.has_column_with_name?('ten').should be_false
+  end
+
   it 'second row should be named_row four' do
     @item_table.named_row('four').items[1].name.value = 'five'
@@ -126,5 +134,10 @@
 
   it 'should be two element at named cell by row column' do
-    @item_table.element_at_named_cell('cluster', 'two').name.value == 'two'
+    @item_table.element_at_named_cell('cluster', 'three').name.value == 'three'
+  end
+
+  it 'should return nil when rows are nil' do
+    @item_table.rows = nil
+    @item_table.row_count.should be_equal 0
   end
 
