Refactor some code and improve test code

Lifting functions refactored for possibility of other boundary conditions.