Added unit tests for boundary conditions
Minor refactoring