Thanks Jan Rudovský for help with this. The code works with Grails 2.3.x. Use Custom Grails Tests for older versions.
The code below shows how to run your custom tests in functional test environment (so the application is running). For the integration tests you will need to use IntegrationTestPhaseConfigurer instead of FunctionalTestPhaseConfigurer.