Add testing trait, remove some copy-and-paste methods
Centralise tests database connection in the common trait