*from what I understand of flashes and metering in canon cameras*
When you use the camera to meter a scene it will read through the lens the availible lighting and, based on the settings and mode you are in, povided the info or change settings so that you will get a "correct" exposure back, correct exposure will be based on your metering mode as normal as well as any possible exposure compensation that you decide to use.
Now when you start using flash for support the camera still can only meter the scene with the current amibent lighting - it does not therefore take into account the fact that the flash is being used*. When you press the shuttter button there is a preflash before the flash fires (this is increadibly quick and hardly noticable) which lets the camera meter the scene with the flash and it sets the flash power output based on that reading - the aperture, shutter speed and ISO all remain the same.
When you used the custom function you forced the camera to shoot at its max sync speed always when the flash is active, which is why the shutter speed jumped up even though the scene before you was still dark. In that case when the flash preflashes it will return a result which will tell the flash to put out more power to the scene to light it better.
The above is why a lot of flash photography where flash is the dominant light source and not simply being used for fill, is done in manual mode - since you the shooter have to take into account the effect of the flash on the scene. You can use an external flash meter and also make use of the histogram in order to take test shots to balance your settings and the flash power output to adjust the effect you get - experience also comes into play here as well.
As for the effect Roy got with the flash of a lit subject and back background (lowkey shooting) that is the effect of the flash light being strong enough to light the main subject, but not having enough power to push light into the further off background - the light diffuses more the further it gets away from the flash and by the background areas the light just does not have the power to return a proper exposure (without blowing out the main subject of course). Using a small aperture and fast shutter speed aids in this process as it increases the amount of light needed at an interval in order to get a correct exposure - the background areas are effectivly exposing without the additional light - hence why you get a black result
* this is excusing full auto modes where the popup flash activates on its own - in those cases the flash is taken into account when used. This I suspect is why Hanno is getting the difference in shutter speeds - in full auto the flash is taken ito account as being active, whilst in aperture priority it is not. This is important as it allows the photographer to use the flash in the semi auto modes as a fill light source as default, rather than the dominant light source - which is what you will get using it in the auto mode every time.