Test files refactoring

First stab, there are still some things which I'm not quite happy yet, but we can work on that later.