added support for rails test mode. small fixes