Finished implementation and adding tests