Add unit tests and refactor a little bit
Rename lib/ -> util/ folder