Fixed generation and added more tests.