Fixed bug in repr() method and add some unit tests