fix sql syntax
Added popen wrapper for the testing