Bug fix + added type assertion tests.