Fix up tests / Refactoring