Fixed getSample and added test for it