Rearranged structure and added test script