Change file structure and add tests