Added validation and new tests