complete and added some unit tests