Card #68 updated v2 sql and testfix