Move some testing setup part into methods, so it is possible to reuse them