implementing branch handling layer and testing of it