Fixes bug in test generation and additional minor changes