Fix bugs in random in Python