Added test cases, refractored pkgs