refactored the command portion to be non-sql specific
Added tests

Signed-off-by: Bert Hajee <hajee@moretIA.com>