fixes AEROGEAR-1360 and AEROGEAR-1361

new interface with nicer callbacks and the missing generateRandom