Fixed bug in CompositeLayer class and added unit test for it

@axeldavy spotted a mistake in my recently merged CompositeLayer PR; I forgot to rename a method in two places. This should fix that and also add a unit test so that it doesn't happen again.

@dwf