Parameterized tests and some refactoring