Updated test generation and fixed various bugs.