Change test naming mechanism.

Re-write the whole class without significant functional changes.