Complete <unitid> in EAD, fixes #3987

Squashed commit of the following:

commit 44121e291d1df8e4d4b532340329aabbff6eb6ab
Author: José Raddaoui Marín <raddaouimarin@gmail.com>
Date:   Fri Feb 22 05:50:44 2013 +0100

    Change attributes order in <unitid>

commit 46425ecd1f12e9cda251ee47ba01cbf11cbdcde2
Author: José Raddaoui Marín <raddaouimarin@gmail.com>
Date:   Fri Feb 22 05:45:08 2013 +0100

    Fix how the repository is taken

commit 2cd7ae9000e896aa00be62a5585d8c9b54fa537a
Author: José Raddaoui Marín <raddaouimarin@gmail.com>
Date:   Fri Feb 22 05:19:17 2013 +0100

    Find repository in the ancestors