fixed __len__ and added tests