tidy NDArray constructors
fix NDArray slice bug and add regression test
tidy code