Making tests a little more independent of resource definition, fixing typecasting on primary key