fix flaky tests

Python 2.6 does not handle float error well as 2.7+

Author: Davies Liu <davies.liu@gmail.com>

Closes #1910 from davies/fix_test and squashes the following commits:

7e51200 [Davies Liu] fix flaky tests

(cherry picked from commit 882da57a1c8c075a87909d516b169b624941a6ec)
Signed-off-by: Michael Armbrust <michael@databricks.com>