Another bunch of tests refactored

The patch is submitted under MIT license.