diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index 6408c15..090f31f 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -25,7 +25,6 @@
 
 
 class BasicOperationsImagesTest(base.BaseV2ImageTest):
-
     """
     Here we test the basic operations of images
     """
@@ -95,7 +94,6 @@
 
 
 class ListImagesTest(base.BaseV2ImageTest):
-
     """
     Here we test the listing of image information
     """
@@ -105,31 +103,114 @@
         super(ListImagesTest, cls).setUpClass()
         # We add a few images here to test the listing functionality of
         # the images API
-        for x in xrange(0, 10):
-            cls._create_standard_image(x)
+        cls._create_standard_image('bare', 'raw')
+        cls._create_standard_image('bare', 'raw')
+        cls._create_standard_image('ami', 'raw')
+        # Add some more for listing
+        cls._create_standard_image('ami', 'ami')
+        cls._create_standard_image('ari', 'ari')
+        cls._create_standard_image('aki', 'aki')
 
     @classmethod
-    def _create_standard_image(cls, number):
+    def _create_standard_image(cls, container_format, disk_format):
         """
         Create a new standard image and return the ID of the newly-registered
         image. Note that the size of the new image is a random number between
         1024 and 4096
         """
         image_file = StringIO.StringIO('*' * random.randint(1024, 4096))
-        name = 'New Standard Image %s' % number
-        resp, body = cls.create_image(name=name, container_format='bare',
-                                      disk_format='raw',
+        name = data_utils.rand_name('image-')
+        resp, body = cls.create_image(name=name,
+                                      container_format=container_format,
+                                      disk_format=disk_format,
                                       visibility='public')
         image_id = body['id']
         resp, body = cls.client.store_image(image_id, data=image_file)
 
         return image_id
 
+    def _list_by_param_value_and_assert(self, params):
+        """
+        Perform list action with given params and validates result.
+        """
+        resp, images_list = self.client.image_list(params=params)
+        self.assertEqual(200, resp.status)
+        # Validating params of fetched images
+        for image in images_list:
+            for key in params:
+                msg = "Failed to list images by %s" % key
+                self.assertEqual(params[key], image[key], msg)
+
     @attr(type='gate')
     def test_index_no_params(self):
         # Simple test to see all fixture images returned
         resp, images_list = self.client.image_list()
         self.assertEqual(resp['status'], '200')
         image_list = map(lambda x: x['id'], images_list)
+
         for image in self.created_images:
             self.assertIn(image, image_list)
+
+    @attr(type='gate')
+    def test_list_images_param_container_format(self):
+        # Test to get all images with container_format='bare'
+        params = {"container_format": "bare"}
+        self._list_by_param_value_and_assert(params)
+
+    @attr(type='gate')
+    def test_list_images_param_disk_format(self):
+        # Test to get all images with disk_format = raw
+        params = {"disk_format": "raw"}
+        self._list_by_param_value_and_assert(params)
+
+    @attr(type='gate')
+    def test_list_images_param_visibility(self):
+        # Test to get all images with visibility = public
+        params = {"visibility": "public"}
+        self._list_by_param_value_and_assert(params)
+
+    @attr(type='gate')
+    def test_list_images_param_size(self):
+        # Test to get all images by size
+        image_id = self.created_images[1]
+        # Get image metadata
+        resp, image = self.client.get_image(image_id)
+        self.assertEqual(resp['status'], '200')
+
+        params = {"size": image['size']}
+        self._list_by_param_value_and_assert(params)
+
+    @attr(type='gate')
+    def test_list_images_param_min_max_size(self):
+        # Test to get all images with size between 2000 to 3000
+        image_id = self.created_images[1]
+        # Get image metadata
+        resp, image = self.client.get_image(image_id)
+        self.assertEqual(resp['status'], '200')
+
+        size = image['size']
+        params = {"size_min": size - 500, "size_max": size + 500}
+        resp, images_list = self.client.image_list(params=params)
+        self.assertEqual(resp['status'], '200')
+        image_size_list = map(lambda x: x['size'], images_list)
+
+        for image_size in image_size_list:
+            self.assertTrue(image_size >= params['size_min'] and
+                            image_size <= params['size_max'],
+                            "Failed to get images by size_min and size_max")
+
+    @attr(type='gate')
+    def test_list_images_param_status(self):
+        # Test to get all available images
+        params = {"status": "available"}
+        self._list_by_param_value_and_assert(params)
+
+    @attr(type='gate')
+    def test_list_images_param_limit(self):
+        # Test to get images by limit
+        params = {"limit": 2}
+        resp, images_list = self.client.image_list(params=params)
+        self.assertEqual(resp['status'], '200')
+
+        self.assertEqual(len(images_list), params['limit'],
+                         "Failed to get images by limit")
