Restructuring and adding tests