added a test that flatMap passes the modified state through correctly