Allow separate working directories for different instances of same program

Currently it is not possible to specify separate working directories for each instance of the [program:x]. In other words following config does not work as one would expect:

        [program:foo]
        process_name = foo_%(process_num)02d
        numprocs = 2
        numprocs_start = 1
        command = foo
        directory = /some/path/foo_%%(process_num)02d

Instead of having different working directories the processes will share the same directory, which is actually chosen randomly (either foo_01 or foo_02) in this case. 

This patch fixes the problem by moving expansion of the directory variable to the correct place, inside the same loop where other instance related variables are expanded.