Added random test generation.
Fixed a bug where the loop would continue to run when a piece would not be put in a contiguous position.