fixed bug in db_query_fmt + other misc bugs
added db_test