add prepared statement option to nn_test
fix creation of the query for multithreading