Link test_rand with math library.

Also deal with size_t to int casts for test_rand printf output.