Turning tests that were buried in client into unit tests and added test showing problem with grain reference in grain state