added unit test and fake malloc (required for unit test)