[SPARK-2862] Fix for a broken test case and add a new test case