Clean lib files.
Add some tests and remove the test thingy from lib.
Improve doc