Changed toClipboard to always return a string

Its non-string form was never used.
Various code cleanup
Split tests into multiple files

Moved the shared code into TestLib.pm
Added a test for database upgrades