Cleaned up aegir module and added tests