Improved lib structure
Added tests