fixed random and added tests