Index: /trunk/psLib/psLib.kdevses
===================================================================
--- /trunk/psLib/psLib.kdevses	(revision 2964)
+++ /trunk/psLib/psLib.kdevses	(revision 2965)
@@ -2,14 +2,29 @@
 <!DOCTYPE KDevPrjSession>
 <KDevPrjSession>
- <DocsAndViews NumberOfDocuments="3" >
+ <DocsAndViews NumberOfDocuments="8" >
   <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/test/fileUtils/tst_psFits.c" >
-   <View0 Type="Source" />
+   <View0 line="22" Type="Source" />
   </Doc0>
   <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/fileUtils/psFits.h" >
-   <View0 Type="Source" />
+   <View0 line="166" Type="Source" />
   </Doc1>
   <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/fileUtils/psFits.c" >
-   <View0 line="318" Type="Source" />
+   <View0 line="257" Type="Source" />
   </Doc2>
+  <Doc3 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImage.h" >
+   <View0 line="0" Type="Source" />
+  </Doc3>
+  <Doc4 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageIO.c" >
+   <View0 line="20" Type="Source" />
+  </Doc4>
+  <Doc5 NumberOfViews="1" URL="file:/home/desonia/psLib/src/fileUtils/psFileUtilsErrors.dat" >
+   <View0 line="20" Type="Source" />
+  </Doc5>
+  <Doc6 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageErrors.dat" >
+   <View0 line="57" Type="Source" />
+  </Doc6>
+  <Doc7 NumberOfViews="1" URL="file:/home/desonia/psLib/src/sysUtils/psLogMsg.h" >
+   <View0 line="0" Type="Source" />
+  </Doc7>
  </DocsAndViews>
  <pluginList>
@@ -21,4 +36,7 @@
    </bookmarks>
   </kdevbookmarks>
+  <kdevsubversion>
+   <subversion recurseresolve="1" recurserelocate="1" recursemerge="1" recursecommit="1" base="" recursepropget="1" recurseswitch="1" recurseupdate="1" recursepropset="1" recursediff="1" recurserevert="1" forcemove="1" recursecheckout="1" forceremove="1" recurseadd="1" recurseproplist="1" forcemerge="1" />
+  </kdevsubversion>
   <kdevvalgrind>
    <executable path="" params="" />
Index: /trunk/psLib/src/dataIO/psFileUtilsErrors.dat
===================================================================
--- /trunk/psLib/src/dataIO/psFileUtilsErrors.dat	(revision 2964)
+++ /trunk/psLib/src/dataIO/psFileUtilsErrors.dat	(revision 2965)
@@ -21,5 +21,6 @@
 psFits_EXTNAME_NULL                    Specified extension name can not be NULL.
 psFits_EXTNAME_INVALID                 Could not find HDU '%s' in file %s.\nCFITSIO Error: %s
-psFits_EXTNUM_INVALID                  Could not find HDU #%d in file %s.\nCFITSIO Error: %s
+psFits_EXTNUM_ABS_MOVE_FAILED          Could not move to specified HDU #%d in file %s.\nCFITSIO Error: %s
+psFits_EXTNUM_REL_MOVE_FAILED          Could not move %d HDUs from current position in file %s.\nCFITSIO Error: %s
 psFits_GET_EXTNUM_FAILED               Failed to determine the current HDU number in file %s.\nCFITSIO Error: %s
 psFits_GETNUMHDUS_FAILED               Failed to determine the number of HDUs in file %s.\nCFITSIO Error: %s
Index: /trunk/psLib/src/dataIO/psFileUtilsErrors.h
===================================================================
--- /trunk/psLib/src/dataIO/psFileUtilsErrors.h	(revision 2964)
+++ /trunk/psLib/src/dataIO/psFileUtilsErrors.h	(revision 2965)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-01-12 22:17:01 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-01-13 01:54:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,5 +43,6 @@
 #define PS_ERRORTEXT_psFits_EXTNAME_NULL "Specified extension name can not be NULL."
 #define PS_ERRORTEXT_psFits_EXTNAME_INVALID "Could not find HDU '%s' in file %s.\nCFITSIO Error: %s"
-#define PS_ERRORTEXT_psFits_EXTNUM_INVALID "Could not find HDU #%d in file %s.\nCFITSIO Error: %s"
+#define PS_ERRORTEXT_psFits_EXTNUM_ABS_MOVE_FAILED "Could not move to specified HDU #%d in file %s.\nCFITSIO Error: %s"
+#define PS_ERRORTEXT_psFits_EXTNUM_REL_MOVE_FAILED "Could not move %d HDUs from current position in file %s.\nCFITSIO Error: %s"
 #define PS_ERRORTEXT_psFits_GET_EXTNUM_FAILED "Failed to determine the current HDU number in file %s.\nCFITSIO Error: %s"
 #define PS_ERRORTEXT_psFits_GETNUMHDUS_FAILED "Failed to determine the number of HDUs in file %s.\nCFITSIO Error: %s"
Index: /trunk/psLib/src/dataIO/psFits.c
===================================================================
--- /trunk/psLib/src/dataIO/psFits.c	(revision 2964)
+++ /trunk/psLib/src/dataIO/psFits.c	(revision 2965)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-01-12 22:17:01 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-01-13 01:54:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -287,16 +287,23 @@
 
     if (relative) {
-        fits_movrel_hdu(fits->p_fd, extnum+1, &hdutype, &status);
+        fits_movrel_hdu(fits->p_fd, extnum, &hdutype, &status);
+        if (status != 0) {
+            char fitsErr[MAX_STRING_LENGTH];
+            fits_get_errstatus(status, fitsErr);
+            psError(PS_ERR_LOCATION_INVALID, true,
+                    PS_ERRORTEXT_psFits_EXTNUM_REL_MOVE_FAILED,
+                    extnum, fits->filename, fitsErr);
+            return false;
+        }
     } else {
         fits_movabs_hdu(fits->p_fd, extnum+1, &hdutype, &status);
-    }
-
-    if (status != 0) {
-        char fitsErr[MAX_STRING_LENGTH];
-        fits_get_errstatus(status, fitsErr);
-        psError(PS_ERR_LOCATION_INVALID, true,
-                PS_ERRORTEXT_psFits_EXTNUM_INVALID,
-                extnum, fits->filename, fitsErr);
-        return false;
+        if (status != 0) {
+            char fitsErr[MAX_STRING_LENGTH];
+            fits_get_errstatus(status, fitsErr);
+            psError(PS_ERR_LOCATION_INVALID, true,
+                    PS_ERRORTEXT_psFits_EXTNUM_ABS_MOVE_FAILED,
+                    extnum, fits->filename, fitsErr);
+            return false;
+        }
     }
 
Index: /trunk/psLib/src/fileUtils/psFileUtilsErrors.dat
===================================================================
--- /trunk/psLib/src/fileUtils/psFileUtilsErrors.dat	(revision 2964)
+++ /trunk/psLib/src/fileUtils/psFileUtilsErrors.dat	(revision 2965)
@@ -21,5 +21,6 @@
 psFits_EXTNAME_NULL                    Specified extension name can not be NULL.
 psFits_EXTNAME_INVALID                 Could not find HDU '%s' in file %s.\nCFITSIO Error: %s
-psFits_EXTNUM_INVALID                  Could not find HDU #%d in file %s.\nCFITSIO Error: %s
+psFits_EXTNUM_ABS_MOVE_FAILED          Could not move to specified HDU #%d in file %s.\nCFITSIO Error: %s
+psFits_EXTNUM_REL_MOVE_FAILED          Could not move %d HDUs from current position in file %s.\nCFITSIO Error: %s
 psFits_GET_EXTNUM_FAILED               Failed to determine the current HDU number in file %s.\nCFITSIO Error: %s
 psFits_GETNUMHDUS_FAILED               Failed to determine the number of HDUs in file %s.\nCFITSIO Error: %s
Index: /trunk/psLib/src/fileUtils/psFileUtilsErrors.h
===================================================================
--- /trunk/psLib/src/fileUtils/psFileUtilsErrors.h	(revision 2964)
+++ /trunk/psLib/src/fileUtils/psFileUtilsErrors.h	(revision 2965)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-01-12 22:17:01 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-01-13 01:54:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -43,5 +43,6 @@
 #define PS_ERRORTEXT_psFits_EXTNAME_NULL "Specified extension name can not be NULL."
 #define PS_ERRORTEXT_psFits_EXTNAME_INVALID "Could not find HDU '%s' in file %s.\nCFITSIO Error: %s"
-#define PS_ERRORTEXT_psFits_EXTNUM_INVALID "Could not find HDU #%d in file %s.\nCFITSIO Error: %s"
+#define PS_ERRORTEXT_psFits_EXTNUM_ABS_MOVE_FAILED "Could not move to specified HDU #%d in file %s.\nCFITSIO Error: %s"
+#define PS_ERRORTEXT_psFits_EXTNUM_REL_MOVE_FAILED "Could not move %d HDUs from current position in file %s.\nCFITSIO Error: %s"
 #define PS_ERRORTEXT_psFits_GET_EXTNUM_FAILED "Failed to determine the current HDU number in file %s.\nCFITSIO Error: %s"
 #define PS_ERRORTEXT_psFits_GETNUMHDUS_FAILED "Failed to determine the number of HDUs in file %s.\nCFITSIO Error: %s"
Index: /trunk/psLib/src/fileUtils/psFits.c
===================================================================
--- /trunk/psLib/src/fileUtils/psFits.c	(revision 2964)
+++ /trunk/psLib/src/fileUtils/psFits.c	(revision 2965)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-01-12 22:17:01 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-01-13 01:54:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -287,16 +287,23 @@
 
     if (relative) {
-        fits_movrel_hdu(fits->p_fd, extnum+1, &hdutype, &status);
+        fits_movrel_hdu(fits->p_fd, extnum, &hdutype, &status);
+        if (status != 0) {
+            char fitsErr[MAX_STRING_LENGTH];
+            fits_get_errstatus(status, fitsErr);
+            psError(PS_ERR_LOCATION_INVALID, true,
+                    PS_ERRORTEXT_psFits_EXTNUM_REL_MOVE_FAILED,
+                    extnum, fits->filename, fitsErr);
+            return false;
+        }
     } else {
         fits_movabs_hdu(fits->p_fd, extnum+1, &hdutype, &status);
-    }
-
-    if (status != 0) {
-        char fitsErr[MAX_STRING_LENGTH];
-        fits_get_errstatus(status, fitsErr);
-        psError(PS_ERR_LOCATION_INVALID, true,
-                PS_ERRORTEXT_psFits_EXTNUM_INVALID,
-                extnum, fits->filename, fitsErr);
-        return false;
+        if (status != 0) {
+            char fitsErr[MAX_STRING_LENGTH];
+            fits_get_errstatus(status, fitsErr);
+            psError(PS_ERR_LOCATION_INVALID, true,
+                    PS_ERRORTEXT_psFits_EXTNUM_ABS_MOVE_FAILED,
+                    extnum, fits->filename, fitsErr);
+            return false;
+        }
     }
 
Index: /trunk/psLib/src/fits/psFits.c
===================================================================
--- /trunk/psLib/src/fits/psFits.c	(revision 2964)
+++ /trunk/psLib/src/fits/psFits.c	(revision 2965)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-01-12 22:17:01 $
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-01-13 01:54:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -287,16 +287,23 @@
 
     if (relative) {
-        fits_movrel_hdu(fits->p_fd, extnum+1, &hdutype, &status);
+        fits_movrel_hdu(fits->p_fd, extnum, &hdutype, &status);
+        if (status != 0) {
+            char fitsErr[MAX_STRING_LENGTH];
+            fits_get_errstatus(status, fitsErr);
+            psError(PS_ERR_LOCATION_INVALID, true,
+                    PS_ERRORTEXT_psFits_EXTNUM_REL_MOVE_FAILED,
+                    extnum, fits->filename, fitsErr);
+            return false;
+        }
     } else {
         fits_movabs_hdu(fits->p_fd, extnum+1, &hdutype, &status);
-    }
-
-    if (status != 0) {
-        char fitsErr[MAX_STRING_LENGTH];
-        fits_get_errstatus(status, fitsErr);
-        psError(PS_ERR_LOCATION_INVALID, true,
-                PS_ERRORTEXT_psFits_EXTNUM_INVALID,
-                extnum, fits->filename, fitsErr);
-        return false;
+        if (status != 0) {
+            char fitsErr[MAX_STRING_LENGTH];
+            fits_get_errstatus(status, fitsErr);
+            psError(PS_ERR_LOCATION_INVALID, true,
+                    PS_ERRORTEXT_psFits_EXTNUM_ABS_MOVE_FAILED,
+                    extnum, fits->filename, fitsErr);
+            return false;
+        }
     }
 
Index: /trunk/psLib/test/dataIO/tst_psFits.c
===================================================================
--- /trunk/psLib/test/dataIO/tst_psFits.c	(revision 2964)
+++ /trunk/psLib/test/dataIO/tst_psFits.c	(revision 2965)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-01-12 22:18:25 $
+*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-01-13 01:54:26 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,8 +22,10 @@
 static psS32 tst_psFitsAlloc( void );
 static psS32 tst_psFitsMoveExtName( void );
+static psS32 tst_psFitsMoveExtNum( void );
 
 testDescription tests[] = {
                               {tst_psFitsAlloc, 801, "psFitsAlloc", 0, false},
                               {tst_psFitsMoveExtName, 802, "psFitsMoveExtName", 0, false},
+                              {tst_psFitsMoveExtNum, 803, "psFitsMoveExtNum", 0, false},
                               {NULL}
                           };
@@ -181,4 +183,162 @@
                 "Operation of NULL extname didn't fail.");
         return 9;
+    }
+
+    psFree(fits);
+
+    return 0;
+}
+
+psS32 tst_psFitsMoveExtNum( void )
+{
+
+    if (! makeMulti() ) {
+        return 1;
+    }
+
+    psFits* fits = psFitsAlloc(multiFilename);
+
+    int numHDUs = psFitsGetSize(fits);
+
+    if (numHDUs < 2) {
+        psError(PS_ERR_UNKNOWN,true,
+                "The 'multi' FITS file does not have multiple HDUs.");
+        return 2;
+    }
+
+    psRegion region = {0,0,0,0};
+
+    // test absolute positioning
+    for (int lcv = 0; lcv < numHDUs; lcv++) {
+        // try to move to the extension
+        if (! psFitsMoveExtNum(fits, lcv, false) ) {
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to move to extension %d.",
+                    lcv);
+            return 3;
+        }
+
+        // check that the image is associated to the extension moved, i.e.,
+        // did we really move to the proper extension?
+        psImage* image = psFitsReadImage(NULL, fits,region,0);
+
+        if (image == NULL || abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) {
+            psError(PS_ERR_UNKNOWN, true,
+                    "The image pixel 0,0 of ext-%d was %g, expected %d.",
+                    lcv,image->data.F32[0][0],lcv);
+            return 4;
+        }
+        psFree(image);
+    }
+
+    for (int lcv = numHDUs-1; lcv >= 0; lcv--) {
+        // try to move to the extension
+        if (! psFitsMoveExtNum(fits, lcv, false) ) {
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to move to extension %d.",
+                    lcv);
+            return 5;
+        }
+
+        // check that the image is associated to the extension moved, i.e.,
+        // did we really move to the proper extension?
+        psImage* image = psFitsReadImage(NULL, fits,region,0);
+
+        if (abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) {
+            psError(PS_ERR_UNKNOWN, true,
+                    "The image pixel 0,0 of ext-%d was %g, expected %d.",
+                    lcv,image->data.F32[0][0],lcv);
+            return 6;
+        }
+        psFree(image);
+    }
+
+    // test relative positioning
+    psFitsMoveExtNum(fits,0,false);
+    for (int lcv = 1; lcv < numHDUs; lcv++) {
+        // try to move to the extension
+        if (! psFitsMoveExtNum(fits, 1, true) ) {
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to move to extension %d.",
+                    lcv);
+            return 13;
+        }
+
+        // check that the image is associated to the extension moved, i.e.,
+        // did we really move to the proper extension?
+        psImage* image = psFitsReadImage(NULL, fits,region,0);
+
+        if (image == NULL || abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) {
+            psError(PS_ERR_UNKNOWN, true,
+                    "The image pixel 0,0 of ext-%d was %g, expected %d.",
+                    lcv,image->data.F32[0][0],lcv);
+            return 14;
+        }
+        psFree(image);
+    }
+
+    for (int lcv = numHDUs-2; lcv >= 0; lcv--) {
+        // try to move to the extension
+        if (! psFitsMoveExtNum(fits, -1, true) ) {
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to move to extension %d.",
+                    lcv);
+            return 15;
+        }
+
+        // check that the image is associated to the extension moved, i.e.,
+        // did we really move to the proper extension?
+        psImage* image = psFitsReadImage(NULL, fits,region,0);
+
+        if (abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) {
+            psError(PS_ERR_UNKNOWN, true,
+                    "The image pixel 0,0 of ext-%d was %g, expected %d.",
+                    lcv,image->data.F32[0][0],lcv);
+            return 16;
+        }
+        psFree(image);
+    }
+
+    // check to see if given a negative extension number, it errors.
+    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error.");
+    if (psFitsMoveExtNum(fits, -1, false) ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "Moving to negative HDU didn't fail.");
+        return 21;
+    }
+
+    // check to see if relative positioning beyond PHU, it errors.
+    psFitsMoveExtNum(fits,0,false);
+    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error.");
+    if (psFitsMoveExtNum(fits, -1, true) ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "Moving to negative HDU didn't fail.");
+        return 22;
+    }
+
+
+    // check to see if given a extension greater than the total #HDUs, it errors.
+    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error.");
+    if (psFitsMoveExtNum(fits, numHDUs, false) ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "Moving to a HDU beyond the file's contents didn't fail.");
+        return 31;
+    }
+
+    // check to see if relative positioning beyond PHU, it errors.
+    psFitsMoveExtNum(fits,numHDUs-1,false);
+    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error.");
+    if (psFitsMoveExtNum(fits, 1, true) ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "Moving to negative HDU didn't fail.");
+        return 32;
+    }
+
+    // check to see if given a NULL psFits, it errors.
+    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error.");
+    if (psFitsMoveExtNum(NULL, 0, false) ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "Operation of NULL psFits didn't fail.");
+        return 40;
     }
 
Index: /trunk/psLib/test/fileUtils/tst_psFits.c
===================================================================
--- /trunk/psLib/test/fileUtils/tst_psFits.c	(revision 2964)
+++ /trunk/psLib/test/fileUtils/tst_psFits.c	(revision 2965)
@@ -6,6 +6,6 @@
 *  @author Robert DeSonia, MHPCC
 *
-*  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-01-12 22:18:25 $
+*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-01-13 01:54:26 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -22,8 +22,10 @@
 static psS32 tst_psFitsAlloc( void );
 static psS32 tst_psFitsMoveExtName( void );
+static psS32 tst_psFitsMoveExtNum( void );
 
 testDescription tests[] = {
                               {tst_psFitsAlloc, 801, "psFitsAlloc", 0, false},
                               {tst_psFitsMoveExtName, 802, "psFitsMoveExtName", 0, false},
+                              {tst_psFitsMoveExtNum, 803, "psFitsMoveExtNum", 0, false},
                               {NULL}
                           };
@@ -181,4 +183,162 @@
                 "Operation of NULL extname didn't fail.");
         return 9;
+    }
+
+    psFree(fits);
+
+    return 0;
+}
+
+psS32 tst_psFitsMoveExtNum( void )
+{
+
+    if (! makeMulti() ) {
+        return 1;
+    }
+
+    psFits* fits = psFitsAlloc(multiFilename);
+
+    int numHDUs = psFitsGetSize(fits);
+
+    if (numHDUs < 2) {
+        psError(PS_ERR_UNKNOWN,true,
+                "The 'multi' FITS file does not have multiple HDUs.");
+        return 2;
+    }
+
+    psRegion region = {0,0,0,0};
+
+    // test absolute positioning
+    for (int lcv = 0; lcv < numHDUs; lcv++) {
+        // try to move to the extension
+        if (! psFitsMoveExtNum(fits, lcv, false) ) {
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to move to extension %d.",
+                    lcv);
+            return 3;
+        }
+
+        // check that the image is associated to the extension moved, i.e.,
+        // did we really move to the proper extension?
+        psImage* image = psFitsReadImage(NULL, fits,region,0);
+
+        if (image == NULL || abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) {
+            psError(PS_ERR_UNKNOWN, true,
+                    "The image pixel 0,0 of ext-%d was %g, expected %d.",
+                    lcv,image->data.F32[0][0],lcv);
+            return 4;
+        }
+        psFree(image);
+    }
+
+    for (int lcv = numHDUs-1; lcv >= 0; lcv--) {
+        // try to move to the extension
+        if (! psFitsMoveExtNum(fits, lcv, false) ) {
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to move to extension %d.",
+                    lcv);
+            return 5;
+        }
+
+        // check that the image is associated to the extension moved, i.e.,
+        // did we really move to the proper extension?
+        psImage* image = psFitsReadImage(NULL, fits,region,0);
+
+        if (abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) {
+            psError(PS_ERR_UNKNOWN, true,
+                    "The image pixel 0,0 of ext-%d was %g, expected %d.",
+                    lcv,image->data.F32[0][0],lcv);
+            return 6;
+        }
+        psFree(image);
+    }
+
+    // test relative positioning
+    psFitsMoveExtNum(fits,0,false);
+    for (int lcv = 1; lcv < numHDUs; lcv++) {
+        // try to move to the extension
+        if (! psFitsMoveExtNum(fits, 1, true) ) {
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to move to extension %d.",
+                    lcv);
+            return 13;
+        }
+
+        // check that the image is associated to the extension moved, i.e.,
+        // did we really move to the proper extension?
+        psImage* image = psFitsReadImage(NULL, fits,region,0);
+
+        if (image == NULL || abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) {
+            psError(PS_ERR_UNKNOWN, true,
+                    "The image pixel 0,0 of ext-%d was %g, expected %d.",
+                    lcv,image->data.F32[0][0],lcv);
+            return 14;
+        }
+        psFree(image);
+    }
+
+    for (int lcv = numHDUs-2; lcv >= 0; lcv--) {
+        // try to move to the extension
+        if (! psFitsMoveExtNum(fits, -1, true) ) {
+            psError(PS_ERR_UNKNOWN, false,
+                    "Failed to move to extension %d.",
+                    lcv);
+            return 15;
+        }
+
+        // check that the image is associated to the extension moved, i.e.,
+        // did we really move to the proper extension?
+        psImage* image = psFitsReadImage(NULL, fits,region,0);
+
+        if (abs(image->data.F32[0][0] - (float)lcv) > FLT_EPSILON) {
+            psError(PS_ERR_UNKNOWN, true,
+                    "The image pixel 0,0 of ext-%d was %g, expected %d.",
+                    lcv,image->data.F32[0][0],lcv);
+            return 16;
+        }
+        psFree(image);
+    }
+
+    // check to see if given a negative extension number, it errors.
+    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error.");
+    if (psFitsMoveExtNum(fits, -1, false) ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "Moving to negative HDU didn't fail.");
+        return 21;
+    }
+
+    // check to see if relative positioning beyond PHU, it errors.
+    psFitsMoveExtNum(fits,0,false);
+    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error.");
+    if (psFitsMoveExtNum(fits, -1, true) ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "Moving to negative HDU didn't fail.");
+        return 22;
+    }
+
+
+    // check to see if given a extension greater than the total #HDUs, it errors.
+    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error.");
+    if (psFitsMoveExtNum(fits, numHDUs, false) ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "Moving to a HDU beyond the file's contents didn't fail.");
+        return 31;
+    }
+
+    // check to see if relative positioning beyond PHU, it errors.
+    psFitsMoveExtNum(fits,numHDUs-1,false);
+    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error.");
+    if (psFitsMoveExtNum(fits, 1, true) ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "Moving to negative HDU didn't fail.");
+        return 32;
+    }
+
+    // check to see if given a NULL psFits, it errors.
+    psLogMsg(__func__,PS_LOG_INFO, "Following should be an error.");
+    if (psFitsMoveExtNum(NULL, 0, false) ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "Operation of NULL psFits didn't fail.");
+        return 40;
     }
 
