Fix spec

Fix the problem that tests on Travis CI sometimes fail.