diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java
index 635f9985def107f9517c0e015666690b71b8f197..57882b31944b9b09f93db81038093d919c383396 100644
--- a/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java
+++ b/rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java
@@ -75,8 +75,8 @@ public abstract class BaseRestImpl {
 	};
 
 	protected Map<String, Object> createAnnotation(MiriamData annotation) {
-		Map<String, Object> result = new HashMap<>();
 		if (annotation != null && annotation.getDataType() != null) {
+			Map<String, Object> result = new HashMap<>();
 			if (annotation.getDataType().getUris().size() > 0) {
 				try {
 					result.put("link", miriamConnector.getUrlString(annotation));
@@ -95,8 +95,10 @@ public abstract class BaseRestImpl {
 			result.put("type", annotation.getDataType().name());
 			result.put("resource", annotation.getResource());
 			result.put("id", annotation.getId());
+			return result;
+		} else {
+			throw new InvalidArgumentException("invalid miriam data: " + annotation);
 		}
-		return result;
 	};
 
 	protected Map<String, Object> createAnnotation(AnnotationView annotation) {
diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImpl.java
index 702cb56cb24015b2109b31f7587346b44f66a22a..949e985122aed64db0eb3d0fc23e3daddfd472a5 100644
--- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImpl.java
+++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImpl.java
@@ -120,7 +120,7 @@ public class ChemicalRestImpl extends BaseRestImpl {
 		this.modelService = modelService;
 	}
 
-	private Map<String, Object> prepareChemical(Chemical chemical, Set<String> columnsSet, List<Model> models) {
+	protected Map<String, Object> prepareChemical(Chemical chemical, Set<String> columnsSet, List<Model> models) {
 		Map<String, Object> result = new HashMap<>();
 
 		String description = "Mesh term not available";
@@ -144,14 +144,18 @@ public class ChemicalRestImpl extends BaseRestImpl {
 			} else if (column.equals("references")) {
 				List<Map<String, Object>> references = new ArrayList<>();
 				references.add(createAnnotation(chemical.getChemicalId()));
-				references.add(createAnnotation(chemical.getCasID()));
+				if (chemical.getCasID() != null) {
+					references.add(createAnnotation(chemical.getCasID()));
+				}
 				value = references;
 			} else if (column.equals("directevidencereferences")) {
 				value = createAnnotations(chemical.getDirectEvidencePublication());
 			} else if (column.equals("description")) {
 				value = description;
 			} else if (column.equals("directevidence")) {
-				value = chemical.getDirectEvidence().getValue();
+				if (chemical.getDirectEvidence() != null) {
+					value = chemical.getDirectEvidence().getValue();
+				}
 			} else if (column.equals("synonyms")) {
 				value = synonyms;
 			} else if (column.equals("targets")) {
@@ -164,7 +168,7 @@ public class ChemicalRestImpl extends BaseRestImpl {
 		return result;
 	}
 
-	private Set<String> createChemicalColumnSet(String columns) {
+	protected Set<String> createChemicalColumnSet(String columns) {
 		Set<String> columnsSet = new HashSet<>();
 		if (columns.equals("")) {
 			columnsSet.add("name");
diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImplTest.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImplTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..86df7fbcaae28d378d477b192b7d459c7fa929a4
--- /dev/null
+++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/chemicals/ChemicalRestImplTest.java
@@ -0,0 +1,67 @@
+package lcsb.mapviewer.api.projects.chemicals;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import lcsb.mapviewer.annotation.data.Chemical;
+import lcsb.mapviewer.annotation.data.ChemicalDirectEvidence;
+import lcsb.mapviewer.annotation.data.ChemicalDirectEvidenceTest;
+import lcsb.mapviewer.api.RestTestFunctions;
+import lcsb.mapviewer.model.map.MiriamData;
+import lcsb.mapviewer.model.map.MiriamType;
+import lcsb.mapviewer.model.map.model.Model;
+import lcsb.mapviewer.services.interfaces.IModelService;
+
+public class ChemicalRestImplTest extends RestTestFunctions {
+	Logger									 logger	= Logger.getLogger(ChemicalRestImplTest.class);
+
+	@Autowired
+
+	private ChemicalRestImpl _drugRestImpl;
+
+	@AfterClass
+	public static void tearDownAfterClass() throws Exception {
+	}
+
+	@Before
+	public void setUp() throws Exception {
+	}
+
+	@After
+	public void tearDown() throws Exception {
+	}
+
+	@Test
+	public void testPrepareChemical() throws Exception {
+		try {
+			Chemical chemical = new Chemical();
+			chemical.setChemicalId(new MiriamData(MiriamType.MESH_2012, "D010300"));
+			Map<String, Object> result = _drugRestImpl.prepareChemical(chemical, _drugRestImpl.createChemicalColumnSet(""), new ArrayList<>());
+			assertNotNull(result);
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
+
+	protected ChemicalRestImpl createMockChemicalRest(String string) throws Exception {
+		Model model = super.getModelForFile(string, true);
+		IModelService mockModelService = Mockito.mock(IModelService.class);
+		Mockito.when(mockModelService.getLastModelByProjectId(anyString(), any())).thenReturn(model);
+		_drugRestImpl.setModelService(mockModelService);
+		return _drugRestImpl;
+	}
+
+}
diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/drugs/DrugRestImplTest.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/drugs/DrugRestImplTest.java
index ecdad6a03327a32a4f42ada6da3b709d121edb99..554b08329a4a9a819b88be5ee1240586b25f4c4c 100644
--- a/rest-api/src/test/java/lcsb/mapviewer/api/projects/drugs/DrugRestImplTest.java
+++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/drugs/DrugRestImplTest.java
@@ -40,7 +40,7 @@ public class DrugRestImplTest extends RestTestFunctions {
 
 	@Test
 	@SuppressWarnings("unchecked")
-	public void testGetModelAsImage() throws Exception {
+	public void testGetDrugsByQuery() throws Exception {
 		try {
 			DrugRestImpl drugRestImpl = createMockProjectRest("testFiles/model/sample.xml");
 			Map<String, Object> result = drugRestImpl.getDrugsByQuery(token.getId(), "sample", "", "nadh").get(0);