Allow custom username and password on tests

This makes the tests read the `MYSQL_USER` and `MYSQL_PASS` environment variables, allowing the tests to run with users other than root.

Since repeating the same pattern over and over on every test would be too much, I've extracted two functions to make the test connection setup.

I've based this on the current master, but I can rebase if you think that #1 is good enough to merge