Improved the implementation of test functions a little.