Changed some embedded fields to references and added unit tests