Add test cases and move testing packages to t/lib