fix always true if conditions
replace 'head -n -1' with BSD-compatible awk call
make tests work with 'with-sqlite=no'