Fix few issues in service_template and make it flake8 compatible

Change creation order - previously there could be
situation where object would be created but it's resource_id was
unset resulting in it being impossible to delete by heat.

Change-Id: If42695b723f31b4e98ecaca12cf1adb2d8decc18