add db constraints and fix autoload tests