Moved postgresql function definition inside the test