test(travis-ci): add missing escape to database script and fix if wrapper

Missing '\' before $db in array_merge was causing the variable to get dropped, and the tests to fail. Also there was a syntax error in the if wrapper which caused the if to make the test fail.