Unit tests + cleaning

Porting of unit tests for net.powermatcher.core and net.powermatcher.api. 
Also did some refactoring and cleaning where applicable