Fix tests to reduce coupling of the code and increase flexibility