Fix behavior of ufuncs, added tests