Add spec helper and refactor testing