added test codes and error handlings