Added tests for database. Added early draft of endpoint verification.

Also removed some old files.
Added proper nonce mechanics. TODO: test them