Added random sampler unit test and fixed bug

Change-Id: Iea62fbcdfdef89b568005a6cdb52a5e39f5589de