Refactored testing code.

Directory structure mirrors that of the library code.