Adding some tests and improving the lib