Fixed a bug with render state caching and added unit tests for it.