More tests added. Substitute function implemented in the core library.