Add more shim tests and fix shim bugs.