change the numpy workaround and added a test. Fixed some xrange usage.