Unit tests

This pull request contains unit tests for the new functions introduced in improving the designer. While writing unit tests I have improved the functions for their testability.