Added aunit tests and corrected one bug, aunit tests are passed