@@ -23,6 +23,15 @@ def ec2():
     mock.stop()
 
 
+def _get_sorted_server_names_from_output(output, separator='\t'):
+    """return server name list from output"""
+    server_names = [
+        row.split(separator)[0]
+        for row in output.rstrip().split('\n') if row != ''
+    ]
+    return sorted(server_names)
+
+
 def test_ec2_up(runner, ec2):
     """jungle ec2 up test"""
     result = runner.invoke(cli.cli, ['ec2', 'up', '-i', ec2['server'].id])
@@ -48,27 +57,27 @@ def test_ec2_down_no_instance(runner, ec2):
 
 
 @pytest.mark.parametrize('arg, expected_server_names', [
-    ('*',  ['server00', 'server01']),
+    ('*',  ['', 'server00', 'server01']),
     ('server01', ['server01']),
     ('fake-server', []),
 ])
 def test_ec2_ls(runner, ec2, arg, expected_server_names):
     """jungle ec2 ls test"""
     result = runner.invoke(cli.cli, ['ec2', 'ls', arg])
     assert result.exit_code == 0
-    assert expected_server_names == [x for x in expected_server_names if x in result.output]
+    assert expected_server_names == _get_sorted_server_names_from_output(result.output)
 
 
 @pytest.mark.parametrize('opt, arg, expected_server_names', [
-    ('-l', '*',  ['server00', 'server01']),
+    ('-l', '*',  ['', 'server00', 'server01']),
     ('-l', 'server01', ['server01']),
     ('-l', 'fake-server', []),
 ])
 def test_ec2_ls_formatted(runner, ec2, opt, arg, expected_server_names):
     """jungle ec2 ls test"""
     result = runner.invoke(cli.cli, ['ec2', 'ls', opt, arg])
     assert result.exit_code == 0
-    assert expected_server_names == [x for x in expected_server_names if x in result.output]
+    assert expected_server_names == _get_sorted_server_names_from_output(result.output, separator=' ')
 
 
 @pytest.mark.parametrize('tags, key, expected', [