Some refactors around tests