moved testcases to library; fixed bugs in meshgridn