Restructured library and added unit testing