I am using the following code for Paypal Express. 
$settings = array(
            'username' => 'XXXX',
            'password' => 'XXX',
            'signature' => 'XXXX',
            'test_mode' => TRUE
        );
while i am using the above code, following error message shown
Merchant_response Object
(
    [_status:protected] => failed
    [_message:protected] => Security header is not valid
    [_reference:protected] => 
    [_data:protected] => 
    [_redirect_url:protected] => 
    [_redirect_method:protected] => GET
    [_redirect_message:protected] => 
    [_redirect_data:protected] => 
)
but, if I changed the test_mode as false, its working fine (redirect to paypal payment page). can any one tell me how I can work test_mode?
I created My API by using the following steps
 Profile -> My Selling Tools -> Selling Online – API Access -> Update -> 
Request API Credentials – Request API signature -> Agree and Submit 
while creating API, where I Specified the Sandbox mode?