tests: Add function to utils to calculate CONFIG_DIR

Based on pull request #809, which doesn't change all tests.

This PR adds a common function to be used by tests to figure out the configdir and adapts the tests to use it.
isn't this all not necessary any longer? (logic is the same as in utils defining CONFIG_DIR)?