ENH: improved test and error checking