Fixed bug in CompositeLayer class and added unit test for it

@axeldavy spotted a mistake in my recently merge CompositeLayer PR (forgot to rename a method somewhere). This should fix that and also add a unit test so that it doesn't happen again

@dwf