Reorganize the code.

Moved tests into separate files.