diff --git a/coverage b/coverage
index 8f9a9bbe1..74785f42c 100755
--- a/coverage
+++ b/coverage
@@ -1,12 +1,12 @@
 #!/bin/bash
 
 working_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
+ 
 # coverage applies only on unit tests
 unit_test_dir='build/tests/unit'
 coverage_dir='build/coverage'
 coverage_file='coverage.info'
-
+ 
 # execute unit tests to generate coverage files
 pushd ${unit_test_dir}
 ctest -R unit
@@ -14,18 +14,39 @@ popd
 
 # generate coverage info files for each unit test binary
 #   + exclude stl, tests and libs
+cd ${working_dir}
 binary_path="${unit_test_dir}/CMakeFiles"
 all_coverage_info=""
 for dir in $binary_path/*.dir; do
     pushd ${dir}
     lcov --gcov-tool ${working_dir}/llvm-gcov -c -d . -o ${coverage_file}
     lcov -r ${coverage_file} '/usr/*' '*/libs/*' '*/tests/*' -o ${coverage_file}
+    test_coverage_file=${working_dir}/${dir}/${coverage_file}
+    if [ -f ${coverage_file} ]; then
+        if [ -s ${coverage_file} ]; then
+            char_no=`wc -c ${coverage_file} | awk '{print $1}'`
+            if [ "${char_no}" -eq "0" ]; then
+                echo "PASS: ${test_coverage_file} contains 0 chars."
+                popd
+                continue
+            fi
+        else
+            echo "PASS: ${test_coverage_file} is empty."
+            popd
+            continue
+        fi
+    else
+        echo "PASS: ${test_coverage_file} doesn't exist."
+        popd
+        continue
+    fi
     all_coverage_info+=" -a ${working_dir}/${dir}/${coverage_file}"
     popd
 done
 
 # merge all info files into total coverage info and generate html
 echo ${all_coverage_info}
+cd ${working_dir}
 mkdir -p ${coverage_dir}
 pushd ${coverage_dir}
 lcov ${all_coverage_info} -o ${coverage_file}
@@ -33,5 +54,6 @@ genhtml ${coverage_file}
 popd
 
 # generage coberatura xml file (compatible with Jenkins)
+cd ${working_dir}
 python libs/lcov-to-cobertura-xml/lcov_cobertura/lcov_cobertura.py \
     ${coverage_dir}/${coverage_file} -o ${coverage_dir}/coverage.xml
diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt
index 706d6412f..52a0dd953 100644
--- a/tests/unit/CMakeLists.txt
+++ b/tests/unit/CMakeLists.txt
@@ -20,7 +20,7 @@ foreach(test_cpp ${test_type_cpps})
     add_executable(${target_name} ${test_cpp})
     set_property(TARGET ${target_name} PROPERTY CXX_STANDARD ${cxx_standard})
     if(${TEST_COVERAGE})
-        set_target_properties(${target_name} PROPERTIES COMPILE_FLAGS "-g -O0 -Wall --coverage -fprofile-arcs -ftest-coverage")
+        set_target_properties(${target_name} PROPERTIES COMPILE_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage")
         set_target_properties(${target_name} PROPERTIES LINK_FLAGS "--coverage -fprofile-arcs -ftest-coverage")
     endif()