Refactored checking structure and wrote more tests