Test modifications and refactoring